.NETGURU
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...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification