473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help! Help! Help!

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
Nov 17 '05 #1
3 1184
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/de...ialogBoxes.asp



if you use MFC you can find usefull reading the following article:
http://msdn.microsoft.com/library/de...menuoption.asp
---

Roman


"Jazzkt" <ja**@msn.com> wrote in message
news:rZIYc.341043$%_6.339973@attbi_s01...
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

Nov 17 '05 #2
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/de...ialogBoxes.asp



if you use MFC you can find usefull reading the following article:
http://msdn.microsoft.com/library/de...menuoption.asp
---

Roman


"Jazzkt" <ja**@msn.com> wrote in message
news:rZIYc.341043$%_6.339973@attbi_s01...
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

Nov 17 '05 #3
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" <ro********@mail.ru> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
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/de...ialogBoxes.asp


if you use MFC you can find usefull reading the following article:
http://msdn.microsoft.com/library/de...menuoption.asp

---

Roman


"Jazzkt" <ja**@msn.com> wrote in message
news:rZIYc.341043$%_6.339973@attbi_s01...
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


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: clintonG | last post by:
Is there a document that explains the difference between the Visual Studio .NET 2003 Combined Help Collection and the MSDN Library for Visual Studio .NET 2003 or does someone have comments...
0
by: Larry Fix | last post by:
I recently added help to a C# application using the Help.ShowHelp method. My compiled help file gets display so that's good. What's not so good is that the help window always starts out with a...
3
by: Tom marsh | last post by:
I'm finishing an application and want to supply help files. However MS Access's help files, ironically don't contain much help on HELP. What is the best approach? I could easily just provide...
11
by: deko | last post by:
What's the best way to create a help system for Access 2003? Is MS HTML Help Workshop the way to go? I want to put a clickable control on different forms, that, when clicked, will bring up the...
0
by: Junkguy | last post by:
Hi, I need help adding help to my Visual Studio 6 C# form application. In searching around the Microsoft C# documentation for Visual Studio, I cannot seem to discover how to add a menu item to...
0
by: Rich Noons | last post by:
Hi, I'm currently trying to link a help file to an application. Everything is linking correctly to the help topics (on the right hand side of the help file). My problem is that the help contents...
1
by: JJ | last post by:
Ok I have now got to grips with HTML help workshop and created my help files, TOC etc. Now how do I integrate this with my application? I have added an errorprovider to my form and pointed it to...
6
by: WhiteWizard | last post by:
Hello all, I have been tasked with coming up with a system for providing help for our users, and we have some somewhat unique requirements. NO INTERNET. This is a windows application that will...
1
by: TJ WIlson | last post by:
Using Windows XP, my Access 2002 program works, but there are no help files. The help window opens, there is nothing there. I've tried repairing the installation, removing the installation and...
0
by: =?Utf-8?B?cnViZW4=?= | last post by:
Hi developers, Maybe this will sound silly, but I need help placing an icon in a menu when setup is build in .Net through a setup project. Really what I need is indicate the help icon (html help...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.