Windows App - C++

A

August1

Hi,

I'm beginning to approach Windows programming in C++. I've written
a short
application which is to do nothing more than demonstrate the Window
style being used. The child windows are not appearing within the
parent window. Could someone point out the cause?

Thank you in advance,
Anthony

#include <windows.h>
#include <string.h>

long WINAPI MainWndProc(HWND,UINT,WPARAM,LPARAM);

HWND hWnd;
HWND hwndEdit;
HWND hwndButton;
HWND hwndClearButton;
char szMessage[50] = "";

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wc;
wc.lpszClassName = "Style1";
wc.lpfnWndProc = MainWndProc;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = "";
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
RegisterClass(&wc);

hWnd = CreateWindow("Style1","Border Demonstration",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
185,265,NULL,NULL,hInstance,NULL);

hwndEdit = CreateWindow("EDIT",NULL,
WS_VISIBLE | WS_CHILD | WS_BORDER | ES_LEFT,
10,10,155,20,hWnd,NULL,hInstance,NULL);

hwndButton = CreateWindow("BUTTON","Message",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,40,35,35,hWnd,NULL,hInstance,NULL);

hwndClearButton = CreateWindow("BUTTON","Clear",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
50,40,35,35,hWnd,NULL,hInstance,NULL);


ShowWindow(hWnd,nCmdShow);

MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}//end WinMain()

long WINAPI MainWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM
lParam)
{
HWND hwndCtl = (HWND)lParam;
switch(msg)
{
case WM_COMMAND:
switch(wParam)
{
case BN_CLICKED:
if(hwndCtl == hwndButton)
{
strcpy(szMessage,"This program is an overlapped style Window.");
SetWindowText(hwndEdit,szMessage);
}
else if(hwndCtl == hwndClearButton)
{
strcpy(szMessage,"");
SetWindowText(hwndEdit,szMessage);
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd,msg,wParam,lParam);
}

return 0;
}//end MainWndProc()
 
V

Victor Bazarov

August1 said:
I'm beginning to approach Windows programming in C++. I've written
a short
application which is to do nothing more than demonstrate the Window
style being used. The child windows are not appearing within the
parent window. Could someone point out the cause? [...]

Somebody in a newsgroup dedicated to Windows programming undoubtedly
could. Here your question is off-topic. Please consider choosing
the newsgroup where to post more carefully.

V
 
A

August1

Somebody in a newsgroup dedicated to Windows programming undoubtedly
could. Here your question is off-topic. Please consider choosing
the newsgroup where to post more carefully.

The Windows API is mainly written in C. Windows applications can be
written in any number of source languages which then make calls to
your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
you may also use the Microsoft Foundation Classes to facilitate
communication with the API and program execution, though not
recommended for cross-platform functionality. The language I am
referencing is C++. The question is not off-topic. I have already
resolved the matter, but if you have nothing pertaining to code
assessment - I have no interest in your suggestion.

Regards
 
J

John Harrison

August1 said:
The Windows API is mainly written in C. Windows applications can be
written in any number of source languages which then make calls to
your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
you may also use the Microsoft Foundation Classes to facilitate
communication with the API and program execution, though not
recommended for cross-platform functionality. The language I am
referencing is C++. The question is not off-topic.

It is. If you want answers instead of abuse try


But if you just want to waste your time, post here!

john
 
J

JKop

The Windows API is mainly written in C. Windows applications can be
written in any number of source languages which then make calls to
your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
you may also use the Microsoft Foundation Classes to facilitate
communication with the API and program execution, though not
recommended for cross-platform functionality. The language I am
referencing is C++. The question is not off-topic. I have already
resolved the matter, but if you have nothing pertaining to code
assessment - I have no interest in your suggestion.


You misunderstand.

You'll hear no mention whatsoever of *any* platform here! We converse here
about what can actually be done with C++ itself and its Standard Libraries.


-JKop
 
R

Randy Yates

The Windows API is mainly written in C. Windows applications can be
written in any number of source languages which then make calls to
your system's API - languages as VB, C++, J++, Foxpro, etc. Using C++
you may also use the Microsoft Foundation Classes to facilitate
communication with the API and program execution, though not
recommended for cross-platform functionality.

All true. Irrelevent, but true.
The language I am referencing is C++. The question is not off-topic.

Oh but it is, just as asking an English teacher for help on your
microbiology homework probably won't be productive even though the
assignment is written in English.
--
% Randy Yates % "...the answer lies within your soul
%% Fuquay-Varina, NC % 'cause no one knows which side
%%% 919-577-9882 % the coin will fall."
%%%% <[email protected]> % 'Big Wheels', *Out of the Blue*, ELO
http://home.earthlink.net/~yatescr
 
M

Mike Wahler

August1 said:
"> But if you just want to waste your time, post here!

Depends on your perceptions. Next.

If you're expecting answers to Windows programming
questions here, be warned that you'll be waiting
a long time. The choice is yours.

-Mike
 
J

JKop

Mike Wahler posted:
If you're expecting answers to Windows programming
questions here, be warned that you'll be waiting
a long time. The choice is yours.

-Mike


Not that long really. Here's an answer:


**** Off


-JKop
 
A

August1

All true. Irrelevent, but true.
Oh but it is, just as asking an English teacher for help on your
microbiology homework probably won't be productive even though the
assignment is written in English.

Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications. Many people today
prefer to use C++ for Windows apps, so they have a greater
understanding of the language and use it for more than console
applications. Therefore they wouldn't find it difficult to answer
console-related or gui-related questions should any be presented.

Regards
 
J

JKop

August1 posted:
Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications.

Not really. I make Win32 Graphical User Interface programs, but I still find
all this irrelevant considering where we are.
Many people today
prefer to use C++ for Windows apps, so they have a greater
understanding of the language and use it for more than console
applications.

Bullshit.

If anything, coding for Windows will just mess up your C++ technique.

Case and point:

#define LRESULT long

Therefore they wouldn't find it difficult to answer
console-related or gui-related questions should any be presented.


Absolutely correct.

Where are we again?



-JKop
 
M

Mike Wahler

August1 said:
Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications. Many people today
prefer to use C++ for Windows apps, so they have a greater
understanding of the language and use it for more than console
applications. Therefore they wouldn't find it difficult to answer
console-related or gui-related questions should any be presented.

You're missing the point again. I'm fairly certain that
many people participating here have good or even expert
knowledge of e.g. GUI programming. They'd not find it
difficult at all to answer questions about it. But they
still don't do it here. Guess why.

John has already given you the name of the group where
your Windows questions will be welcomed with open arms.
If you go there, you'll even see his name, and articles
by him discussing Windows. But I now wonder if he'll
help you even there, given your behavior here.

Here is the "official" document defining the purpose
of comp.lang.c++:

http://www.slack.net/~shiva/welcome.txt

Please read it carefully before posting here again. Thank you.

-Mike
 
V

Victor Bazarov

Mike said:
[...]
Here is the "official" document defining the purpose
of comp.lang.c++:

http://www.slack.net/~shiva/welcome.txt

Please read it carefully before posting here again. Thank you.

Mike, I wish I had your patience. I hope you're not really
holding your breath that 'August1' will read the welcome msg.
I'd really be disappointed if you suffocate.
 
R

Randy Yates

Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications. Many people today
prefer to use C++ for Windows apps, so they have a greater
understanding of the language and use it for more than console
applications. Therefore they wouldn't find it difficult to answer
console-related or gui-related questions should any be presented.

Oh dear. I'm afraid I've thrown pearls before swine. I'm not sure
what number would be less, your IQ or number of years in school.
 
M

Mike Wahler

Victor Bazarov said:
Mike said:
[...]
Here is the "official" document defining the purpose
of comp.lang.c++:

http://www.slack.net/~shiva/welcome.txt

Please read it carefully before posting here again. Thank you.

Mike, I wish I had your patience.

It comes and goes. :)
I hope you're not really
holding your breath that 'August1' will read the welcome msg.

Not really, but I decided I'd give him one last chance.
Nobody had posted that link in this thread yet. We'll see.
But I have indeed been glancing at my plonk button.
I'd really be disappointed if you suffocate.

Thanks for caring about me. :)

-Mike
 
P

Phlip

August1 said:
Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications. Many people today
prefer to use C++ for Windows apps, so they have a greater
understanding of the language and use it for more than console
applications. Therefore they wouldn't find it difficult to answer
console-related or gui-related questions should any be presented.

Oh, dear. Yet another newbie challenging the topicality protocols.

Why don't we all just discuss keyboard layouts while we're at it?

August1, only an elite minority are capable of answering technical
questions, on fora of _their_ choice, and you are danged lucky to have such
a wide selection of them. However, posting to the narrowest technical
newsgroup possible is

==> in your best interest. <==

If, for example, you post a Linux question to a Microsoft newsgroup, you
very well might get a good answer, and a hearty discussion. If you instead
post to a Linux newsgroup, the regulars there will _compete_ with each other
to provide the best answer. They will review each others' answers, provide
emmendments and additions, and generally aid the Linux cause.

Apologies on behalf of my e-siblings who can only phrase this in terms of
territory - "you are off-topic, so get lost". That's stimulating to write,
but hardly enfranchising to read. You yourself can also try to do better.
 
D

Default User

August1 wrote:

Irrelevent only to those who find it irrelevent, or dedicate much of
their time in C/C++ with console applications.

You've been told that this is off-topic. Instead of acknowledging that
and apologizing, you argue. To what end? Do you think you'll
everybody's mind. Instead, what happens is this:


*plonk*




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top