Re: Setting caption programatically on DialogBox



Strangely addding the DS_SETFOREGROUND flag solved this. I may
start with a dummy resource file and then use the API to alter the fields
in WM_INITDIALOG, thanks for all your help

"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjkcru452hq2f@xxxxxxxxxxx

It is probably because DLGTEMPLATE is normally followed by
some additional data, while you are passing exactly DLGTEMPLATE
buffer.

Just for testing, try something like that:


BYTE buf[ 64 ];

ZeroMemory(buf, sizeof(buf));

DLGTEMPLATE *dlgSched = (DLGTEMPLATE *)buf;

dlgSched->style = DS_CENTER | WS_SYSMENU | WS_CAPTION | WS_POPUP;
dlgSched->dwExtendedStyle = WS_EX_CAPTIONOKBTN;
dlgSched->cx = 80;
dlgSched->cy = 40;
dlgSched->cdit = 0;
dlgSched->x = 30;
dlgSched->y = 30;

DialogBoxIndirect(g_hInst,dlgSched,NULL,DlgProc);



On Wed, 27 Sep 2006 16:28:38 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

Doing a bit of testing it doesn't matter if i have a main message loop or
background
thread, if i create dialog box as i have done programatically, there is a
delay
in the client area being painted. ie i get a dialog box with the client
area
transpareant and then a noticeable fraction of a second later it gets
painted
white. What i want is to have the Client area appearing same time as
everything else.


"JB" <JB@xxxxxxxxxxxxxx> wrote in message
news:%2350O9$j4GHA.3364@xxxxxxxxxxxxxxxxxxxxxxx
I create dialog box in InitInstance so this is before my background
thread
is created. I've put it here for now just to test and was wondering why
there was a delay in the client area being painted

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
g_hInst = hInstance; // Store instance handle in our global variable


DLGTEMPLATE *dlgSched = new DLGTEMPLATE;

dlgSched->style = DS_CENTER | WS_SYSMENU | WS_CAPTION | WS_POPUP;
dlgSched->dwExtendedStyle = WS_EX_CAPTIONOKBTN;
dlgSched->cx = 80;
dlgSched->cy = 40;
dlgSched->cdit = 0;
dlgSched->x = 30;
dlgSched->y = 30;

DialogBoxIndirect(g_hInst,dlgSched,NULL,DlgProc);

return TRUE;
}




"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjivnem52hq2f@xxxxxxxxxxx

I'm confused by the message loop. Why do you need
it if you don't have a main window? Also, when do
you show your dialog box?

Try to remove your background thread creation and check
whether the problem is still there (i.e. not caused by
the background thread).



On Wed, 27 Sep 2006 15:46:41 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

Yes i have one background thread running which sleeps
for 300ms checks the registry for some data and then goes
back to sleep. I don't have a main window just a message loop.

int WINAPI WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTR lpCmdLine,

int nCmdShow)

{

MSG msg;

HANDLE hThread;

DWORD dwThreadId;

Perform application initialization:

if (!InitInstance(hInstance, nCmdShow)) {

return FALSE;

}


//Create a background thread which periodically scans the registry

hThread = CreateThread(NULL, 0,RegThread,NULL,0,(DWORD*)&dwThreadId);

if(!hThread){

return FALSE;

}

// Main message loop:

while (GetMessage(&msg, NULL, 0, 0)) {

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return (int) msg.wParam;

}

For now i'm creating the DialogBox in the InitInstance just to test it

"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjgfqii52hq2f@xxxxxxxxxxx

Looks ok to me. Well, are you handling any timer
or custom messages in your main (or others) window
proc the time dialog box is shown? Do you have any
background threads running?


On Wed, 27 Sep 2006 14:53:09 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

BOOL CALLBACK DlgProc(HWND hWnd,
UINT wMsg,
WPARAM wParam,
LPARAM lParam)
{
switch(wMsg){
case WM_INITDIALOG:
SetWindowsText(hWnd, _T(""))
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)){
case IDOK :
case IDCANCEL : EndDialog(hWnd, 0); return TRUE;
}
break;
}
return FALSE;
}


"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjdp6vz52hq2f@xxxxxxxxxxx

Post your DlgProc() code here



On Wed, 27 Sep 2006 14:03:13 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

yes thanks, one thing i noticed when i create it with
DialogBoxindirect
as
below
the client area is slow to be painted, the outline and title bar
including
ok button
come up right off so why the delay?

"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjcn1t852hq2f@xxxxxxxxxxx

You can grab it (the dialog handle) in your DlgProc
when processing the WM_INITDIALOG message.


On Wed, 27 Sep 2006 13:38:39 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

Thanks but i don't have DialogWindow handle i created like this.
The app does not have a main window it will just pop up a skinnable
dialog box.

DLGTEMPLATE *dlgSched = new DLGTEMPLATE;
dlgSched->style = DS_CENTER | WS_SYSMENU | WS_CAPTION | WS_POPUP;
dlgSched->dwExtendedStyle = WS_EX_CAPTIONOKBTN;
dlgSched->cx = 80;
dlgSched->cy = 40;
dlgSched->cdit = 0;
dlgSched->x = 30;
dlgSched->y = 30;
DialogBoxIndirect(g_hInst,dlgSched,NULL,DlgProc);

"voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:op.tgjatjvz52hq2f@xxxxxxxxxxx

Use SetWindowsText(DialogWindowHandle, _T("your caption"))


On Wed, 27 Sep 2006 13:07:19 +0200, JB <JB@xxxxxxxxxxxxxx> wrote:

Hi, I'm develping PocketPC app, I've created a dialog box by
filling
in
template DLGTEMPLATE structure. I want to set the caption of the
dialog box programatically. How do i do this? I'm basically
creating
a
skinnable dialog box in VS2005 C++ are there any samples to do
this?

Thanks























.