Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crerat Button's Parameters ??

Status
Not open for further replies.

mianaziz

Programmer
Jun 19, 2002
18
0
0
PK
hello
did any one tell me that
when we creat a button

CButton myButton;

// Create a bitmap button.
myButton.Create(_T("My Button"),WS_CHILD|WS_VISIBLE|BS_BITMAP,
CRect(10,10,60,50), pParentWnd, 1);


tell me pParentWnd ?? how we get this Parameter

and tell me weather Creat will creat button or i have to first place the button the Dialog box?

please helpme i am almost new one

Bye

 
the parent window should be a pointer to the window/dialog that you are placing the button onto. It is a lot easier to place your button on the dialog in the resource editor. Then use class wizard to add a member variable for the button of type CButton. You can specify in the resource properties for the button that the button uses a bitmap rather than text.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
pParentWnd should be equal to "this" if you are creating the button in the window constructor.

The other thing is that passing "1" as the ID of the button may not be a good idea, because all values from 0-99 are reserved for the system. Best Regards,

aphrodita@mail.krovatka.ru {uiuc rules}
 
hi

probeum is this that pointer to parent window is needed mostly in programing.

but i am not still able to get pParem pointer to main window

help me in getting this through coading..

bye
 
If you need a pointer to the main frame window of your app call AfxGetMainWnd().....[tt]

CWnd* pParent = ::AfxGetMainWnd();
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
If you need a pointer to the main frame window of your app call AfxGetMainWnd().....[tt]

CWnd* pParent = ::AfxGetMainWnd(); [/tt]

If you simply need a pointer to the window/dialog which will contain a button then you use the [tt]this[/tt] pointer - provided it is being created within the window/dialog class

[tt]myButton.Create(_T("My Button"),WS_CHILD|WS_VISIBLE|BS_BITMAP,
CRect(10,10,60,50),this, 1);
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
hi

thanks for coperating. but

i also need to know that how i can get the pointer of main dialog box and also its handle.

thanks

bye
 
When you create a new dialog in the resource editor, if you right-click the mouse VC++ asks you whether you want to create a new class for the dialog. Click Yes and VC++ will create the class and some base code for you.
To display the dialog you would #include the header for this new dialog in some other part of your code and then create an instance of the dialog there:[tt]

// assume dialog created in resource editor and
// class created - the dialog class is called
// MyDialog

#include "MyDialog.h"

void SomeOtherClass::SomeFunction()
{
// create a MyDialog object and display it
MyDialog dlg;
dlg.DoModal();

// to get a pointer to this dialog do this:
CDialog* pDlg = &dlg;
}[/tt]

tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top