FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Window handle

 
Post new topic   Reply to topic     Forum Index -> ArcLib
View previous topic :: View next topic  
Author Message
HateWork



Joined: 20 Oct 2007
Posts: 13

PostPosted: Sat Jan 26, 2008 8:45 pm    Post subject: Window handle Reply with quote

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
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Jan 28, 2008 9:47 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
HateWork



Joined: 20 Oct 2007
Posts: 13

PostPosted: Wed Jan 30, 2008 12:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
ChristianK



Joined: 26 Sep 2006
Posts: 159
Location: Berlin, Germany

PostPosted: Wed Jan 30, 2008 1:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
Brix



Joined: 28 Oct 2006
Posts: 21
Location: EU, Denmark, Lyngby.

PostPosted: Thu Jan 31, 2008 5:23 pm    Post subject: Reply with quote

You can use D's import expression for embedding any type of stuff at compile time.

http://digitalmars.com/d/1.0/expression.html#ImportExpression
Back to top
View user's profile Send private message MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Jan 31, 2008 9:32 pm    Post subject: Reply with quote

Where there's a will, there's a way. Smile

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
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Jan 31, 2008 9:44 pm    Post subject: Reply with quote

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! Smile

-JJR
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> ArcLib All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group