• Advertisement

Archived

This topic is now archived and is closed to further replies.

includeing user32.dll in my project, how?

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Or add user32.lib to the linker settings in your project''s properties dialog box. (Properties->Linker->Input->Additional Dependencies.

Just so you understand what''s going on, user32.lib is the symbol library for user32.dll. user32.lib basically tells the compiler that the actual code is in user32.dll, so by linking to user32.lib at compile time, user32.dll will be loaded up automatically for use by your executable when you run it.

Share this post


Link to post
Share on other sites
i want use the FlashWindow() function which it is not supported in .NET.
So i want use CWindow::FlashWindow(bool) inside my code.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There''s nothing lazy about #pragma, it is just not protable since it is compiler specific. But, since user32.lib is pretty non portable, I don''t see any problem. It saves you the headache also of having to setup your linker settings if you lose your workspace.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
for a windows app, VC++ includes the import library for user32.dll by default - you should need to do nothing for that.

When you''re talking about CWindow::FlashWindow(...) I think that you''re using MFC (going by the class name). Obviously it must be an MFC project (I''m not trying to be insulting here...)

Again, you don''t call CWindow::FlashWindow(...) like that, you''ll need to call the function on a particular instanitation (ie m_mainWindow.FlashWindow(TRUE); ).

Or are you trying to do this for a non-MFC app ? in which case the call is:
FlashWindow(hWnd, TRUE);

If this doesn''t help explain what you are trying to do a little better (MFC / non-MFC, it''s not a C# project is it ???, snipet of code arround the area your trying to flash the window etc.)

Share this post


Link to post
Share on other sites
i need to do FlashWindow(hWnd, TRUE);
but declaring HWND variables (or whatever it could be) is not possible in .NET.
All the members of this-> or of my window, has not hWnd access.
So i can''t call FlashWindow(hWnd, TRUE);
another time FlashWindow() is not accessible in .net, i must include something to use it without errors.
But what???

Share this post


Link to post
Share on other sites

You don''t just mean this?:


[DllImport("User32.dll")]
public static extern int FlashWindow(int hwnd, int invert);


This doesn''t work if you input 0 to hwnd? No probably not. The only way I can think of is using the FindWindow function first to find it''s own window, and then use FlashWindow to flash it.

Also... do not despair: things are about to improve.

Hope this helps,

Edo

Share this post


Link to post
Share on other sites

Also, lookup the MainWindowHandle property of the System.Diagnostic.Process class... I think this is the solution.

Edo

Share this post


Link to post
Share on other sites
quote:
Original post by edotorpedo

You don''t just mean this?:


[DllImport("User32.dll")]
public static extern int FlashWindow(int hwnd, int invert);


This doesn''t work if you input 0 to hwnd? No probably not. The only way I can think of is using the FindWindow function first to find it''s own window, and then use FlashWindow to flash it.

Also... do not despair: things are about to improve.

Hope this helps,

Edo





where must i put these lines?

[DllImport("User32.dll")]public static extern int FlashWindow(int hwnd, int invert);

Share this post


Link to post
Share on other sites
Anywhere, it just declares a function that is implemented externally (hence extern). Something like this:


class MyWindowClass
{

[DllImport("User32.dll")]
private static extern int FlashWindow (int hwnd, int invert);

public void animateWindow()
{

int hwnd = GetWindowHandle() // use MainWindowHandle property for this

FlashWindow(hwnd, true);

}

}



Let me know if you can retrieven the hwnd using the Process class.

Edo

[edited by - edotorpedo on January 14, 2004 9:00:57 AM]

Share this post


Link to post
Share on other sites
this is the code:
					 int hwnd = (int)this->Handle;
FlashWindow(hwnd, false);


These are the errors i get if i use this function normally:

c:\...\Form1.h(128): error C3861: ''FlashWindow'': identifier not found, even with argument-dependent lookup

c:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(3778): error C2365: ''FlashWindow'' : redefinition; previous definition was a ''formerly unknown identifier''

Share this post


Link to post
Share on other sites
The code posted before was C#, not C++.
To the OP, what error message did you get before adding the DllImport part?

Share this post


Link to post
Share on other sites

  • Advertisement