Help! Help! Help!
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.

Post a new message to this list...

Jazzkt
Hello, Folks,

I am new to VC++ and I just added a form to my application. The GUI has a
group of checkboxes, a combo box, a text box and two buttons.

Will someone please walk me through getting the form to load and displayed
on my screen?

I greatly appreciate the help.

jazz

Reply to this message...
 
    
Roman Yankin
The answer depends on what technique you are using. Is it pure WinAPI or MFC
or ATL.... etc

Basically here you can find the simplest way to initialize and display
dialog box is to execute the following piece of code:

#include <windows.h>

#define MY_CLASS_NAME "MyClass"
#define MY_WINDOW_TITLE "MyTitle"

/* Prototype */
LRESULT CALLBACK
WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
WNDCLASS wc;
HWND hwnd;

/* Register the window class for the main window. */
if( hPrevInstance == NULL )
{
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( (HINSTANCE)NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( (HINSTANCE)NULL, IDC_ARROW );
wc.hbrBackground = GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = 0;
wc.lpszClassName = MY_CLASS_NAME;
if ( RegisterClass( &wc ) == 0 )
return 0;
}

/* Create our window. */
hwnd = CreateWindow( MY_CLASS_NAME, MY_WINDOW_TITLE, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)NULL, (HMENU)NULL, hInstance, (LPVOID)NULL );
/*
* If the window cannot be created, terminate
* the application.
*/
if( hwnd == NULL )
return 0;

/* Show the window and paint its contents. */
ShowWindow( hwnd, nCmdShow );
UpdateWindow( hwnd );

/* Start the message loop. */
while( GetMessage( &msg, (HWND)NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}

/* Return the exit code to the system. */
return msg.wParam;
}

#include <windows.h>

LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam )
{

HINSTANCE hinst = (HINSTANCE)::GetWindowLong(hwnd, GWL_HINSTANCE);
witch( uMsg )
{

case WM_CREATE:

//Here is where dialog box will appear using your template

::DialogBox(hinst, MAKEINTRESOURCE(DLG_WINDOW), hwnd,
(DLGPROC)DlgWndProc)==IDOK
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hwnd, uMsg, wParam, lParam ) );
}
return 0;
}
~~~~~~~~~~~~~~~

Rememeber to replace DLG_WINDOW with the ID of your own dialog window

Read the following article in order to decide whether you need to use modal
or modeless dialog box. It will also help you to write your own Dialog
procedure:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/DialogBoxes/UsingDialogBoxes.asp

if you use MFC you can find usefull reading the following article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vchowexampledisplayingdialogboxviamenuoption.asp

---

Roman

"Jazzkt" <Click here to reveal e-mail address> wrote in message
news:rZIYc.341043$%_6.339973@attbi_s01...
[Original message clipped]

Reply to this message...
 
    
Lord2702
Hey this guy is not talking about MFC form, or typical old (Petzold) style
window procedure. he is talking about WinForm of dot net 2003.
just press Ctrl-F5 and your form will be on your screen.

"Roman Yankin" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> The answer depends on what technique you are using. Is it pure WinAPI or
MFC
[Original message clipped]

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com