SDLNet IPv4 to numerical addresses

I’m sure that this question has been answered at one point or another, but
how would i use the IPaddress type in SDLNet and convert it so i’d see an IP
address like 127.0.0.1 ?

this is what I tried (and failed miserably):

IPaddress *ip;
int *numip;
char *charip;

numip = (int *)ip;

sprintf( charip, “%d.%d.%d.%d”, numip[0], numip[1], numip[2], numip[3] );

this gave me a bunch of jibberish, evidently. I’m pretty sure i’m close to
it, but unfortunately not close enough.

I used to program in a language called ‘freebasic’ that had sdlnet ported -
free basic had a cool function ‘cptr( pointer type, cast )’ that I was able
to use to get the numerical address by converting the ip into a bunch of
unsigned bytes - unfortunately, c++ doesn’t have this luxury…any thoughts?

thanks,
Alex~

This might be a silly question but here it goes.

After using SDL with OpenGL for several years with win32 as my main
plattform I now decided to save some time and not code an OpenGL GUI but use
a simple win32 dialog box to make some kind of gui.

But to my surprise it didnt seem to be possible to create dialog boxes when
using SDL.
I did a quick test and removed the SDL window init code and made a regular
win32 window and then the dialog box creation worked.

Am I wrong about not being able to do dialog boxes when using SDL?
And if not, is there a way to work around it?

From http://www.libsdl.org/cgi/docwiki.cgi/IPaddress:
typedef struct {
Uint32 host; /* 32-bit IPv4 host address /
Uint16 port; /
16-bit protocol port */
} IPaddress;

So you can just use

int numip; // not a pointer
numip = ip->host;

to make things clearer, or you can just use ip.host instead of the
numip intermediary.

To read the individual bytes of your 32 bit int, you can do a little
bitwise operator voodoo. (( numip >> 24) & 0xff) will give you an
int with a value equal to the largest order byte in the int, (( numip

16 ) & 0xff ) the second largest order byte, (( numip >> 8 ) &
0xff ) the third, and ( numip & 0xff ) the last.

Looking at your solution, I think it actually might have worked if
you declared numip as a char * rather than an int * (since you want
the individual bytes), but its correctness could be dependent on the
endianness of the host system (not sure about that though).

Your solution doesnt work because you are treating the IPAddress as
an array of 4 32-bit integers, when you really want to treat it as an
array of 4 8-bit integers.

As a side note, I remember the old Mac OS had hiword(), loword(),
hibyte(), lobyhte(), etc. macros that made these things a lot easier.

spencerOn Mar 12, 2006, at 9:44 AM, Alex Barry wrote:

I’m sure that this question has been answered at one point or
another, but how would i use the IPaddress type in SDLNet and
convert it so i’d see an IP address like 127.0.0.1 ?

this is what I tried (and failed miserably):

IPaddress *ip;
int *numip;
char *charip;

numip = (int *)ip;

sprintf( charip, “%d.%d.%d.%d”, numip[0], numip[1], numip[2], numip
[3] );

this gave me a bunch of jibberish, evidently. I’m pretty sure i’m
close to it, but unfortunately not close enough.

I used to program in a language called ‘freebasic’ that had sdlnet
ported - free basic had a cool function ‘cptr( pointer type,
cast )’ that I was able to use to get the numerical address by
converting the ip into a bunch of unsigned bytes - unfortunately, c+

  • doesn’t have this luxury…any thoughts?

thanks,
Alex~


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

This might be a silly question but here it goes.

After using SDL with OpenGL for several years with win32 as my main
plattform I now decided to save some time and not code an OpenGL GUI but use
a simple win32 dialog box to make some kind of gui.

But to my surprise it didnt seem to be possible to create dialog boxes when
using SDL.
I did a quick test and removed the SDL window init code and made a regular
win32 window and then the dialog box creation worked.

This is a bug, which has been reported but nobody has figured out why
it doesn’t work. Please post if you figure it out!

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

But to my surprise it didnt seem to be possible to create dialog boxes when
using SDL.

This is a bug, which has been reported but nobody has figured out why
it doesn’t work. Please post if you figure it out!

Could it be related to what’s discussed in this thread
http://thread.gmane.org/gmane.comp.lib.sdl/26191? I’m describing a
solution there that works for me, but it seems it doesn’t work for everyone.

-Christian

Hi,

I’ve had a look at it and it is caused by the creation of a temporary
window in Init_WGL_ARB_extensions() in SDL_wingl.c which injects some
messages into the application message queue.

I tried a few things, like changing:

hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP|WS_DISABLED, …

into:

hwnd = CreateWindow(“STATIC”, NULL, WS_POPUP|WS_DISABLED, …

but I’m not confident that a static text control window will always be
happy having an OpenGL context attached to it :o) so I also tried a call
to FlushMessageQueue() after the DestroyWindow() call at the end of
Init_WGL_ARB_extensions().

They both worked, but I finally settled on using the existing device
context, GL_hdc, and just removing the window and dc creation /
destruction functionsr: see the attached patch.

Is there any good reason NOT to just use this existing DC?

I’ve attached a test program that reproduces the problem and allowed me
to determine that it happens with both windib and directx drivers and
doesn’t happen unless OpenGL is enabled.

A quick comment/compile/test binary search through the source led me to
Init_WGL_ARB_extensions(),

cheers,
John Popplewell.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: msgbox.c
Type: text/x-csrc
Size: 2303 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060313/5b84b186/attachment.c
-------------- next part --------------
Index: src/video/wincommon/SDL_wingl.cOn Sun, Mar 12, 2006 at 05:54:28PM -0800, Sam Lantinga wrote:

This might be a silly question but here it goes.

After using SDL with OpenGL for several years with win32 as my main
plattform I now decided to save some time and not code an OpenGL GUI but use
a simple win32 dialog box to make some kind of gui.

But to my surprise it didnt seem to be possible to create dialog boxes when
using SDL.
I did a quick test and removed the SDL window init code and made a regular
win32 window and then the dialog box creation worked.

This is a bug, which has been reported but nobody has figured out why
it doesn’t work. Please post if you figure it out!

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/video/wincommon/SDL_wingl.c,v
retrieving revision 1.29
diff -u -r1.29 SDL_wingl.c
— src/video/wincommon/SDL_wingl.c 7 Mar 2006 05:21:32 -0000 1.29
+++ src/video/wincommon/SDL_wingl.c 13 Mar 2006 15:26:41 -0000
@@ -108,18 +108,12 @@

static void Init_WGL_ARB_extensions(_THIS)
{

  • HWND hwnd;
  • HDC hdc;
  • HDC hdc = GL_hdc;
    HGLRC hglrc;
    int pformat;
    const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0;
    const char *extensions;
  • hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED,
  •                   0, 0, 10, 10,
    
  •                   NULL, NULL, SDL_Instance, NULL);
    
  • hdc = GetDC(hwnd);
  • pformat = ChoosePixelFormat(hdc, &GL_pfd);
    SetPixelFormat(hdc, pformat, &GL_pfd);

@@ -156,8 +150,6 @@
this->gl_data->wglMakeCurrent(NULL, NULL);
this->gl_data->wglDeleteContext(hglrc);
}

  • ReleaseDC(hwnd, hdc);
  • DestroyWindow(hwnd);
    }

#endif /* SDL_VIDEO_OPENGL */

Hello Tomas,

Sunday, March 12, 2006, 5:28:16 PM, you wrote:

TJ> This might be a silly question but here it goes.

TJ> After using SDL with OpenGL for several years with win32 as my main
TJ> plattform I now decided to save some time and not code an OpenGL GUI but use
TJ> a simple win32 dialog box to make some kind of gui.

TJ> But to my surprise it didnt seem to be possible to create dialog boxes when
TJ> using SDL.
TJ> I did a quick test and removed the SDL window init code and made a regular
TJ> win32 window and then the dialog box creation worked.

TJ> Am I wrong about not being able to do dialog boxes when using SDL?
TJ> And if not, is there a way to work around it?

Show us your dialog code. Are you just calling DialogBox() ?–
Best regards,
Peter mailto:@Peter_Mulholland

Hello Sam,

Monday, March 13, 2006, 1:54:28 AM, you wrote:

SL> This is a bug, which has been reported but nobody has figured out why
SL> it doesn’t work. Please post if you figure it out!

Having just looked at the win32 message pump loops inside
SDL_dibevents.c and SDL_dx5events.c I don’t see why they’re written
the way they are. This would work better:

  while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
  {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
  }

The call to TranslateMessage() is most likely not needed as all this
does is intercept some keyboard messages and produces WM_CHAR and
WM_SYSDEADCHAR which are not used anyway.

I wondered if you need IsDialogMessage() in the main loop but again,
that’s only concerned with keyboard controls.

I’m a bit stumped for now but i’ll look into it. If memory serves
though, we’ve shipped beta test stuff on Windows that uses SDL, and
I’ve had quite a few of the testers tell me that an Assert dialog has
popped up (this is windowed mode, not fullscreen). So i don’t get it.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi John. I tried that patch from you and it didnt fix anything. I saw in
your test app that you displayed a MessageBox and those have never been a
problem. Im trying to create a DialogBox using this:

Dialog = CreateDialog (GetModuleHandle (NULL),
MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, NULL);

if (Dialog)
ShowWindow (Dialog, SW_SHOW);

Error = GetLAstError ();

and it fails without returning any error. IT just wont create any DialogBox.

I also tried the FlushMessageQueue by adding this before the call to
CreateDialog:

while (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&Message);
DispatchMessage (&Message);
}

and that didnt change anything either.
Ill spend some more time altering various bits of SDL and see if I can find
anything more.

// Tomaz

----Original Message Follows----From: john@johnnypops.demon.co.uk (John Popplewell)
Reply-To: “A list for developers using the SDL library.
(includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 15:31:51 +0000

On Sun, Mar 12, 2006 at 05:54:28PM -0800, Sam Lantinga wrote:

This might be a silly question but here it goes.

After using SDL with OpenGL for several years with win32 as my main
plattform I now decided to save some time and not code an OpenGL GUI
but use

a simple win32 dialog box to make some kind of gui.

But to my surprise it didnt seem to be possible to create dialog boxes
when

using SDL.
I did a quick test and removed the SDL window init code and made a
regular

win32 window and then the dialog box creation worked.

This is a bug, which has been reported but nobody has figured out why
it doesn’t work. Please post if you figure it out!

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Hi,

I’ve had a look at it and it is caused by the creation of a temporary
window in Init_WGL_ARB_extensions() in SDL_wingl.c which injects some
messages into the application message queue.

I tried a few things, like changing:

hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP|WS_DISABLED, …

into:

hwnd = CreateWindow(“STATIC”, NULL, WS_POPUP|WS_DISABLED, …

but I’m not confident that a static text control window will always be
happy having an OpenGL context attached to it :o) so I also tried a call
to FlushMessageQueue() after the DestroyWindow() call at the end of
Init_WGL_ARB_extensions().

They both worked, but I finally settled on using the existing device
context, GL_hdc, and just removing the window and dc creation /
destruction functionsr: see the attached patch.

Is there any good reason NOT to just use this existing DC?

I’ve attached a test program that reproduces the problem and allowed me
to determine that it happens with both windib and directx drivers and
doesn’t happen unless OpenGL is enabled.

A quick comment/compile/test binary search through the source led me to
Init_WGL_ARB_extensions(),

cheers,
John Popplewell.

<< msgbox.c >>

<< msgbox-patch.txt >>


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Tomas,

Monday, March 13, 2006, 6:43:47 PM, you wrote:

TJ> Hi John. I tried that patch from you and it didnt fix anything. I saw in
TJ> your test app that you displayed a MessageBox and those have never been a
TJ> problem. Im trying to create a DialogBox using this:

TJ> Dialog = CreateDialog (GetModuleHandle (NULL),
TJ> MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, NULL);

TJ> if (Dialog)
TJ> ShowWindow (Dialog, SW_SHOW);

TJ> Error = GetLAstError ();

TJ> and it fails without returning any error. IT just wont create any DialogBox.

You are doing it wrong. Those last two params must not be NULL.

You need the parent window handle (can get that from SDL_GetWMInfo())
and a Dialog proc function to handle the dialog’s messages. I’m not
sure if you can pass HWND_DESKTOP for the parent window and it still
works…

I don’t know why that’s working in a standalone shell, possibly
because in your standalone shell, the app has not already registered a
window of its own.–
Best regards,
Peter mailto:@Peter_Mulholland

Im sorry. The code i pasted was the wrong code.
This is the actual code.

pLights->Dialog = CreateDialog (GetModuleHandle (NULL),
MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, Edit_Proc);

if (pLights->Dialog)
ShowWindow (pLights->Dialog, SW_SHOW);

This is the actual code is it is now when not using SDL for anything and
this works just fine.

You do not need a parent window to get the dialog box to display.
In fact. IF you give it a parentwindow then you will not get it showing in
the taskbar and can not ALT+TBA between the game window and the DialogBox.
And who has said anything about a standalone shell?
I clearly stated that this works when creating a window using regular win32
code and not using SDL so there is nothing wrong with how i create my
DialogBox.

// Tomaz

----Original Message Follows----From: darkmatter@freeuk.com (Peter Mulholland)
Reply-To: Peter Mulholland ,“A list for developers
using the SDL library. (includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 19:36:43 +0000

Hello Tomas,

Monday, March 13, 2006, 6:43:47 PM, you wrote:

TJ> Hi John. I tried that patch from you and it didnt fix anything. I saw in
TJ> your test app that you displayed a MessageBox and those have never been
a
TJ> problem. Im trying to create a DialogBox using this:

TJ> Dialog = CreateDialog (GetModuleHandle (NULL),
TJ> MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, NULL);

TJ> if (Dialog)
TJ> ShowWindow (Dialog, SW_SHOW);

TJ> Error = GetLAstError ();

TJ> and it fails without returning any error. IT just wont create any
DialogBox.

You are doing it wrong. Those last two params must not be NULL.

You need the parent window handle (can get that from SDL_GetWMInfo())
and a Dialog proc function to handle the dialog’s messages. I’m not
sure if you can pass HWND_DESKTOP for the parent window and it still
works…

I don’t know why that’s working in a standalone shell, possibly
because in your standalone shell, the app has not already registered a
window of its own.


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Tomas,

Monday, March 13, 2006, 7:56:39 PM, you wrote:

TJ> Im sorry. The code i pasted was the wrong code.
TJ> This is the actual code.

pLights->>Dialog = CreateDialog (GetModuleHandle (NULL),
TJ> MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, Edit_Proc);

if (pLights->>Dialog)
TJ> ShowWindow (pLights->Dialog, SW_SHOW);

TJ> This is the actual code is it is now when not using SDL for anything and
TJ> this works just fine.

TJ> You do not need a parent window to get the dialog box to display.
TJ> In fact. IF you give it a parentwindow then you will not get it showing in
TJ> the taskbar and can not ALT+TBA between the game window and the DialogBox.

Hmm.

The catch is that dialogs are not really proper windows, hence why the
dialog proc is different to a window proc. Yes, this is totally stupid
of MS to do it this way.

It must be something to do with the message loop that’s inside the
display drivers, handling the input events. If you don’t call
SDL_PumpEvents regularly, the windows message loop doesn’t run.
This could mean important setup messages are never dispatched, and
therefore your dialog window never appears

Try opening your dialog, then calling SDL_PumpEvents in a bit of a
loop, and see if your dialog works then.

TJ> And who has said anything about a standalone shell?

By “shell” i meant as you said:

TJ> I did a quick test and removed the SDL window init code and made a regular
TJ> win32 window and then the dialog box creation worked.

shell as in quick test code, not as in command line. Sorry :slight_smile:

TJ> I clearly stated that this works when creating a window using regular win32
TJ> code and not using SDL so there is nothing wrong with how i create my
TJ> DialogBox.

Do you have the normal GetMessage/DispatchMessage loop in your test
code?–
Best regards,
Peter mailto:@Peter_Mulholland

This is the code i use in the regular win32 code:

while (PeekMessage (&Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&Message);
DispatchMessage (&Message);

if (Message.message == WM_QUIT)
    pBase->Quit = TRUE;

}

and this is the code i use in the SDL code:

while (SDL_PollEvent (&Event))
{
… lots and lots of code to grab input and other stuff
}

Which is run each frame.
I just did a test and ran both the SDL_PollEvents loop AND the plain win32
PeekMessage thing right before creating my DialogBox just to be sure that
all messages are flushed out and it still wont show up.
A simple MessageBox works just fine tho.

MessageBox (NULL, “Test”, “Test”, MB_OK);

// Tomaz

----Original Message Follows----From: darkmatter@freeuk.com (Peter Mulholland)
Reply-To: Peter Mulholland ,“A list for developers
using the SDL library. (includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 20:08:31 +0000

Hello Tomas,

Monday, March 13, 2006, 7:56:39 PM, you wrote:

TJ> Im sorry. The code i pasted was the wrong code.
TJ> This is the actual code.

pLights->>Dialog = CreateDialog (GetModuleHandle (NULL),
TJ> MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, Edit_Proc);

if (pLights->>Dialog)
TJ> ShowWindow (pLights->Dialog, SW_SHOW);

TJ> This is the actual code is it is now when not using SDL for anything and
TJ> this works just fine.

TJ> You do not need a parent window to get the dialog box to display.
TJ> In fact. IF you give it a parentwindow then you will not get it showing
in
TJ> the taskbar and can not ALT+TBA between the game window and the
DialogBox.

Hmm.

The catch is that dialogs are not really proper windows, hence why the
dialog proc is different to a window proc. Yes, this is totally stupid
of MS to do it this way.

It must be something to do with the message loop that’s inside the
display drivers, handling the input events. If you don’t call
SDL_PumpEvents regularly, the windows message loop doesn’t run.
This could mean important setup messages are never dispatched, and
therefore your dialog window never appears

Try opening your dialog, then calling SDL_PumpEvents in a bit of a
loop, and see if your dialog works then.

TJ> And who has said anything about a standalone shell?

By “shell” i meant as you said:

TJ> I did a quick test and removed the SDL window init code and made a
regular
TJ> win32 window and then the dialog box creation worked.

shell as in quick test code, not as in command line. Sorry :slight_smile:

TJ> I clearly stated that this works when creating a window using regular
win32
TJ> code and not using SDL so there is nothing wrong with how i create my
TJ> DialogBox.

Do you have the normal GetMessage/DispatchMessage loop in your test
code?


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Tomas,

Monday, March 13, 2006, 8:22:00 PM, you wrote:

TJ> This is the code i use in the regular win32 code:

TJ> while (PeekMessage (&Message, NULL, 0, 0, PM_REMOVE))
TJ> {
TJ> TranslateMessage (&Message);
TJ> DispatchMessage (&Message);

TJ> if (Message.message == WM_QUIT)
TJ> pBase->Quit = TRUE;
TJ> }

TJ> and this is the code i use in the SDL code:

TJ> while (SDL_PollEvent (&Event))
TJ> {
TJ> … lots and lots of code to grab input and other stuff
TJ> }

TJ> Which is run each frame.

Hmm, this does seem to produce the right result…

TJ> I just did a test and ran both the SDL_PollEvents loop AND the plain win32
TJ> PeekMessage thing right before creating my DialogBox just to be sure that
TJ> all messages are flushed out and it still wont show up.
TJ> A simple MessageBox works just fine tho.

This should work because MessageBox blocks, and presumably runs it’s
own message loop. The odd thing is people have been saying assert() in
Visual C++ fails, which calls MessageBox. Very odd.–
Best regards,
Peter mailto:@Peter_Mulholland

I just tested and assert also works just fine.
Also tried to create a second window using CreateWindow (); and that also
failed.

// Tomaz

----Original Message Follows----From: darkmatter@freeuk.com (Peter Mulholland)
Reply-To: Peter Mulholland ,“A list for developers
using the SDL library. (includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 21:12:22 +0000

Hello Tomas,

Monday, March 13, 2006, 8:22:00 PM, you wrote:

TJ> This is the code i use in the regular win32 code:

TJ> while (PeekMessage (&Message, NULL, 0, 0, PM_REMOVE))
TJ> {
TJ> TranslateMessage (&Message);
TJ> DispatchMessage (&Message);

TJ> if (Message.message == WM_QUIT)
TJ> pBase->Quit = TRUE;
TJ> }

TJ> and this is the code i use in the SDL code:

TJ> while (SDL_PollEvent (&Event))
TJ> {
TJ> … lots and lots of code to grab input and other stuff
TJ> }

TJ> Which is run each frame.

Hmm, this does seem to produce the right result…

TJ> I just did a test and ran both the SDL_PollEvents loop AND the plain
win32
TJ> PeekMessage thing right before creating my DialogBox just to be sure
that
TJ> all messages are flushed out and it still wont show up.
TJ> A simple MessageBox works just fine tho.

This should work because MessageBox blocks, and presumably runs it’s
own message loop. The odd thing is people have been saying assert() in
Visual C++ fails, which calls MessageBox. Very odd.


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

This is the code i use in the regular win32 code:

while (PeekMessage (&Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&Message);
DispatchMessage (&Message);

if (Message.message == WM_QUIT)
    pBase->Quit = TRUE;

}

and this is the code i use in the SDL code:

while (SDL_PollEvent (&Event))
{
… lots and lots of code to grab input and other stuff
}

Which is run each frame.
I just did a test and ran both the SDL_PollEvents loop AND the plain win32
PeekMessage thing right before creating my DialogBox just to be sure that
all messages are flushed out and it still wont show up.
A simple MessageBox works just fine tho.

MessageBox (NULL, “Test”, “Test”, MB_OK);

// Tomaz

Hi Tomaz,

thanks for the clarification. This is a different bug from the one
addressed by my patch. You are using a modeless dialog whilst the main
message loop is running, I was addressing the problem of displaying
error message boxes after the main loop has terminated - sorry about
that.

I’ll get back to you later if I find a solution to your problem,

cheers,
John.On Mon, Mar 13, 2006 at 09:22:00PM +0100, Tomas Jakobsson wrote:

----Original Message Follows----
From: Peter Mulholland
Reply-To: Peter Mulholland ,“A list for developers
using the SDL library. (includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 20:08:31 +0000

Hello Tomas,

Monday, March 13, 2006, 7:56:39 PM, you wrote:

TJ> Im sorry. The code i pasted was the wrong code.
TJ> This is the actual code.

pLights->>Dialog = CreateDialog (GetModuleHandle (NULL),
TJ> MAKEINTRESOURCE(IDD_DIALOG_LIGHTS), NULL, Edit_Proc);

if (pLights->>Dialog)
TJ> ShowWindow (pLights->Dialog, SW_SHOW);

TJ> This is the actual code is it is now when not using SDL for anything and
TJ> this works just fine.

TJ> You do not need a parent window to get the dialog box to display.
TJ> In fact. IF you give it a parentwindow then you will not get it showing
in
TJ> the taskbar and can not ALT+TBA between the game window and the
DialogBox.

Hmm.

The catch is that dialogs are not really proper windows, hence why the
dialog proc is different to a window proc. Yes, this is totally stupid
of MS to do it this way.

It must be something to do with the message loop that’s inside the
display drivers, handling the input events. If you don’t call
SDL_PumpEvents regularly, the windows message loop doesn’t run.
This could mean important setup messages are never dispatched, and
therefore your dialog window never appears

Try opening your dialog, then calling SDL_PumpEvents in a bit of a
loop, and see if your dialog works then.

TJ> And who has said anything about a standalone shell?

By “shell” i meant as you said:

TJ> I did a quick test and removed the SDL window init code and made a
regular
TJ> win32 window and then the dialog box creation worked.

shell as in quick test code, not as in command line. Sorry :slight_smile:

TJ> I clearly stated that this works when creating a window using regular
win32
TJ> code and not using SDL so there is nothing wrong with how i create my
TJ> DialogBox.

Do you have the normal GetMessage/DispatchMessage loop in your test
code?


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Tomas,

Monday, March 13, 2006, 9:15:43 PM, you wrote:

TJ> I just tested and assert also works just fine.
TJ> Also tried to create a second window using CreateWindow (); and that also
TJ> failed.

Just want to clear something up, are you doing SDL_SetVideoMode()
before opening a dialog? What video driver is being used, windib or
dx5?–
Best regards,
Peter mailto:@Peter_Mulholland

SDL_SetVideoMode is called before and I dont know which driver is used,
whichever id default.

Now comes the scary part tho. I tried creating this dialog box as the first
thing in my main () before doing anything else. It still fails, while in the
non SDL version of the same game engine it works just fine…
Im getting kinda tired of this problem/bug

Ill be damn if it has anything to do with even linking in SDL… Or maybe
the headers are doing something?
Time for some more detective work.

// Tomaz

----Original Message Follows----From: darkmatter@freeuk.com (Peter Mulholland)
Reply-To: Peter Mulholland ,“A list for developers
using the SDL library. (includesSDL-announce)”
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] Dialog boxes.
Date: Mon, 13 Mar 2006 21:36:27 +0000

Hello Tomas,

Monday, March 13, 2006, 9:15:43 PM, you wrote:

TJ> I just tested and assert also works just fine.
TJ> Also tried to create a second window using CreateWindow (); and that
also
TJ> failed.

Just want to clear something up, are you doing SDL_SetVideoMode()
before opening a dialog? What video driver is being used, windib or
dx5?


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Tomas,

Monday, March 13, 2006, 9:52:31 PM, you wrote:

TJ> SDL_SetVideoMode is called before and I dont know which driver is used,
TJ> whichever id default.

TJ> Now comes the scary part tho. I tried creating this dialog box as the first
TJ> thing in my main () before doing anything else. It still fails, while in the
TJ> non SDL version of the same game engine it works just fine…
TJ> Im getting kinda tired of this problem/bug

TJ> Ill be damn if it has anything to do with even linking in SDL… Or maybe
TJ> the headers are doing something?
TJ> Time for some more detective work.

We could see if it’s the window setup SDL does. Try making a window
yourself and using setenv(“SDL_WINDOWID”) to get SDL to use it.–
Best regards,
Peter mailto:@Peter_Mulholland

Tomaz,

the attached code displays an OpenGL/SDL window and a modeless dialog.
I’m using the current CVS version of SDL. Works OK here.

Please show us a small, complete example that exhibits the problem,

best regards,
John.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: resource.h
Type: text/x-chdr
Size: 91 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060313/92577ac3/attachment.h
-------------- next part --------------
#include “winuser.h”

#include “resource.h”

/////////////////////////////////////////////////////////////////////////////

//

// Dialog

//

IDD_DIALOG_LIGHTS DIALOG DISCARDABLE 0, 0, 186, 61

STYLE DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU

CAPTION “Modeless Dialog”

FONT 8, “MS Sans Serif”

BEGIN

DEFPUSHBUTTON   "OK",IDOK,65,35,55,14

CTEXT           "Click to Close!",IDC_ERROR_TEXT,40,15,110,20

END

-------------- next part --------------
A non-text attachment was scrubbed…
Name: modeless.c
Type: text/x-csrc
Size: 1729 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060313/92577ac3/attachment.cOn Mon, Mar 13, 2006 at 09:22:00PM +0100, Tomas Jakobsson wrote:

This is the code i use in the regular win32 code:

while (PeekMessage (&Message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage (&Message);
DispatchMessage (&Message);

if (Message.message == WM_QUIT)
    pBase->Quit = TRUE;

}

and this is the code i use in the SDL code:

while (SDL_PollEvent (&Event))
{
… lots and lots of code to grab input and other stuff
}

Which is run each frame.
I just did a test and ran both the SDL_PollEvents loop AND the plain win32
PeekMessage thing right before creating my DialogBox just to be sure that
all messages are flushed out and it still wont show up.
A simple MessageBox works just fine tho.

MessageBox (NULL, “Test”, “Test”, MB_OK);

// Tomaz