Mr. Thunder_Tw

Hi,

My goal is to create a DLL that provides usefull functions wich give you a DialogWindow.

This has to be programmed in a way that only default DynamicLinkLibrarys(.DLL) files are used.

So I'm useing C++ and WIN32, working in Visual Studio 2005.

I have a few problems where I can't find the appropriate help for.

1st- Adding a "Button" and/or "Edit" to the Dialogs can only be done right after the CreateWindowEX function where i Create the Dialog-Window with ( all the help files state this should be done in the WndProc function when Msg == WM_CREATE )

If though I'm looking into example-code downed from the internet, this ain't a problem when I'm compiling them.

2nd- I'm not recieving messages like WM_GETDLGCODE WM_NEXTDLGCTL WM_INITDIALOG

3rd- While using WS_TABSTOP when creating the Buttons and Edit-boxes: pressing the tab-key has NO result on Buttons and in a Edit-box it's resulting ONLY in a MessageBeep.

4th- How do I allow only digits in a specified Edit-box

Window Creating (password asking dialogbox):

Code Snippet

DWORD dwExStyle; // Window Extended Style

DWORD dwStyle; // Window Style

RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values

RECT DeskRect;

WindowRect.left = (long)0; // Set Left Value To 0

WindowRect.right = (long)width; // Set Right Value To Requested Width

WindowRect.top = (long)0; // Set Top Value To 0

WindowRect.bottom = (long)height; // Set Bottom Value To Requested Height

GetClientRect( GetDesktopWindow(), &DeskRect );

WNDCLASS wc; // Windows Class Structure

wc.style = CS_HREDRAW | CS_VREDRAW; // | CS_OWNDC; // Redraw On Size, And Own DC For Window.

wc.lpfnWndProc = (WNDPROC)WndProc; // WndProc Handles Messages

wc.cbClsExtra = 0; // No Extra Window Data

wc.cbWndExtra = 0; //DLGWINDOWEXTRA; // No Extra Window Data

wc.hInstance = m_hInstance; // Set The Instance

wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon

//wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); // WNDCLASSEX // Load The Default Icon

wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer

wc.hbrBackground = (HBRUSH)GetSysColorBrush( COLOR_3DFACE ); // What Color we want in our background

wc.lpszMenuName = NULL; // We Don't Want A Menu

wc.lpszClassName = m_appName; // Set The Class Name

if( !RegisterClass( &wc ) ) // Attempt To Register The Window Class

{

return false; // Return FALSE

}

dwStyle = WS_CAPTION | WS_VISIBLE | WS_SYSMENU | WS_OVERLAPPED | WS_POPUP;

dwExStyle = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_WINDOWEDGE | WS_EX_DLGMODALFRAME;

AdjustWindowRectEx( &WindowRect, dwStyle, FALSE, dwExStyle ); // Adjust Window To True Requested Size

if( !( m_hWnd = Active_hWnd = CreateWindowEx( dwExStyle, // Extended Style For The Window

m_appName, // Class Name

title, // Window Title

dwStyle, // Defined Window Style

DeskRect.right/2 - (WindowRect.right-WindowRect.left)/2, // X In the middle

DeskRect.bottom/2 - (WindowRect.bottom-WindowRect.top)/2, // // Y In the middle

WindowRect.right-WindowRect.left, // Calculate Window Width

WindowRect.bottom-WindowRect.top, // Calculate Window Height

Parent, // No Parent Window

NULL, // No Menu

m_hInstance, // Instance

NULL ))) // Dont Pass Anything To WM_CREATE

{

KillWindow( ); // Reset The Display

return false; // Return FALSE

}

HWND hOkButton = CreateWindow(

"BUTTON", "Ok", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON,

clientRect.right - 160, clientRect.bottom - 36, 72, 24,

m_hWnd, (HMENU)IDB_OK, m_hInstance, NULL );

HWND hCancelButton = CreateWindow(

"BUTTON", "Cancel", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_TEXT,

clientRect.right - 80, clientRect.bottom - 36, 72, 24,

m_hWnd, (HMENU)IDB_CANCEL, m_hInstance, NULL );

HWND hTextEdit = CreateWindowEx( WS_EX_CLIENTEDGE,

"EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | WS_BORDER | ES_PASSWORD,

clientRect.right/2 - 50, clientRect.bottom - 80, 160, 26,

m_hWnd, (HMENU)IDC_EDIT, m_hInstance, NULL );

Thanks in advance



Re: Visual C++ General WIN32 problems

Mr. Thunder_Tw

Nr 4 has been solved with adding ES_NUMBER in the dwStyle

the other 3 problems are still active

Thanks in advance




Re: Visual C++ General WIN32 problems

Mr. Thunder_Tw

I've solved problem Nr 2 and Nr 3 using the following messageloop ( thx P.A.!! )

Code Snippet

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

{

if( NULL == m_hWnd || !IsDialogMessage( m_hWnd, &msg ) )

{

TranslateMessage( &msg ); // Translate The Message

DispatchMessage( &msg ); // Dispatch The Message

}

}

most importand in this snippet is the function IsDialogMessage( m_hWnd, &msg )

Problem Nr 1 is dropped for it's answer wouldn't help much now.

Thread solved!

Thanks annyway!!





Re: Visual C++ General WIN32 problems

Simple Samples

Your question indicates you are creating a dialog but you are not creating a dialog. That is no problem if you understand that but if not then you might get confused expecting a dialog and not getting one. Your window is a regular window, not a dialog.