944,085 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 8972
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 17th, 2005
0

Win32 - Controls on main window

Expand Post »
Hi, I have recently started windows programming in C/C++, I understand most of it, but 1 thing i cant find out how to do is to put controls on the main window of the application, not in a popup dialog box...can anyone give me any tips on how to do this ? thanks in advance ?
Reputation Points: 23
Solved Threads: 5
Posting Whiz in Training
bops is offline Offline
214 posts
since Aug 2005
Dec 17th, 2005
0

Re: Win32 - Controls on main window

during the window's initialization, use the control's Create function, in which you specify the parent HWND, RECT containing the location and height, and the control's ID, among other things. The instance object of the control must NOT be local to a function, but global in the c++ class or program file in which it is used because it must stay in scope during the lifetime of the window.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Dec 17th, 2005
0

Re: Win32 - Controls on main window

Thanks, that makes a lot of sense lol...I will give that a go...is there any way of specifying the design of the window in the resource file in the way you can design your dialog box and menus etc ?
Reputation Points: 23
Solved Threads: 5
Posting Whiz in Training
bops is offline Offline
214 posts
since Aug 2005
Dec 17th, 2005
0

Re: Win32 - Controls on main window

Oh also, do you have any good links on where I can get lists of styles etc for dialog boxes (Im not sure what they are called) and all fo the other kinds of controls etc for example...

C++ Syntax (Toggle Plain Text)
  1. DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
  2. MB_OK | MB_ICONERROR
  3. //and lots more...
Reputation Points: 23
Solved Threads: 5
Posting Whiz in Training
bops is offline Offline
214 posts
since Aug 2005
Dec 17th, 2005
0

Re: Win32 - Controls on main window

well, if the number of controls is small, using global variables is okay. but i prefer to create them locally inside the create function and then use GetDialogItem API to get the handles of the controls when i need them. this eliminates the need of global window handles and makes the program less messy.

the best site regarding the apis is the msdn site itself.
Individual Controls
dialogs
The list of values can be obtained in CreateWindow

as for specyfing the design of the window like a dialog box, i have found a way to do that yet using a resource editor.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Dec 18th, 2005
0

Re: Win32 - Controls on main window

Quote originally posted by bops ...
.is there any way of specifying the design of the window in the resource file in the way you can design your dialog box and menus etc ?
use CFormView instead of CView and the view will look and act like a dialog box -- and you can design it like one too.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Dec 19th, 2005
0

Re: Win32 - Controls on main window

Quote originally posted by me ...
as for specyfing the design of the window like a dialog box, i have found a way to do that yet using a resource editor.
I meant i have NOT found a way to do that yet. at least not in pure win32.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Dec 20th, 2005
0

Re: Win32 - Controls on main window

Hello again guys, I am having a lot of trouble simply setting the properties of controls on a dialog box, for example setting a command button to enabled and disabled, i have spent hours on msdn looking for ways of doing this but i still manage to get confused....also what is CView and CFormView and do you have any links to download a free decent resource editor? thanks.
Reputation Points: 23
Solved Threads: 5
Posting Whiz in Training
bops is offline Offline
214 posts
since Aug 2005
Dec 20th, 2005
0

Re: Win32 - Controls on main window

CView and CFormView are MFC c++ classes. But you need to use VC++ 6.0 or newer to use them. Call the win32 api function EnableWindow() to enable and disable buttons and most other windows too.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,957 posts
since Aug 2005
Dec 21st, 2005
0

Re: Win32 - Controls on main window

oh i see, i have tried all kinds of ways including enablewindow(); function, could you give me an example on using it to disable a command button please?
Reputation Points: 23
Solved Threads: 5
Posting Whiz in Training
bops is offline Offline
214 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: How to "delete" this memory???
Next Thread in C++ Forum Timeline: File array question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC