View previous topic :: View next topic |
Author |
Message |
HateWork
Joined: 20 Oct 2007 Posts: 13
|
Posted: Sat Jan 26, 2008 8:45 pm Post subject: Window handle |
|
|
I'm doing my first attempts to use arc under win32, i want to know how can i get the handle to the main window?. I want to do this because i want to use the resource api from win32 to load strings and images from the exe file. |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon Jan 28, 2008 9:47 pm Post subject: |
|
|
I'm not sure what you are trying to do, can you explain in more detail?
With Arc, there should be no need to access the win32 api directly. |
|
Back to top |
|
|
HateWork
Joined: 20 Oct 2007 Posts: 13
|
Posted: Wed Jan 30, 2008 12:43 pm Post subject: |
|
|
It is simple, i want to embedd images, strings and other stuff into the executable (resource file), then if you want to load a string for example you would use LoadString from the win32 api, but this function takes as an argument the handle of the main window to know from where read resources. |
|
Back to top |
|
|
ChristianK
Joined: 26 Sep 2006 Posts: 159 Location: Berlin, Germany
|
Posted: Wed Jan 30, 2008 1:16 pm Post subject: |
|
|
We've never done that. Since we use SDL to create the window in a platform-independent way, I expect you'll just have to look up the appropriate SDL function to get the window handle.
But that'll make your game win32 only. I don't recommend it. |
|
Back to top |
|
|
Brix
Joined: 28 Oct 2006 Posts: 21 Location: EU, Denmark, Lyngby.
|
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Thu Jan 31, 2008 9:32 pm Post subject: |
|
|
Where there's a will, there's a way.
There are other alternatives, like the others mentioned, that would better encourage portability. But there are also a few win32 functions that might do the trick if you are intent on going this route.
Just make sure that you have access to win32 bindings, then give something like "FindWindow(...)" a try?
A quick search on google:
http://msdn2.microsoft.com/en-us/library/ms633499.aspx
With the first argument set to null and the second set to the window name, it appears to be possible to retrieve the window handle. I imagine the window name is the same as you would set during sdl creation.
I haven't tried this, but I figured it may be of use here.
-JJR |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Thu Jan 31, 2008 9:44 pm Post subject: |
|
|
Scratch that... it appears that you don't even need to use win32 functions.
A search of SDL itself reveals this function that you may use to retrieve the platforms window manager information:
int SDL_GetWMInfo(SDL_SysWMinfo *info);
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fGetWMInfo
And the structure SDL_SysWMinfo is described here:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSysWMInfo
Which shows that you can get the exact information you need for each platorm. In this case, win32 is:
Code: | typedef struct {
SDL_version version;
HWND window; /* The Win32 display window */
HGLRC hglrc; /* The OpenGL context, if any */
} SDL_SysWMinfo;
|
So just stick to SDL!
-JJR |
|
Back to top |
|
|
|