-
very simple
i know the basic C++ language, but i have only worked with console applications and im used to the Visual Basic way of coding
my big problem is how do i reference (in code) a control name that is on a dialog?
like in VB you just do cmdWhatever.Caption = "Hello"
is it like IDC_BUTTON1.Caption("Hello"); in C++?
thanx
-
One wat is to use GetDlgItem()
so if you wanted to set the text of IDC_BUTTON1
you could do...
GetDlgItem(IDC_BUTTON1)->SetWindowText("Button");
GetDlgItem() returns a pointer to a CWnd object (base class for the majority MFC)... If you wanna do a control specific task you can just cast the the pointer...
((CListBox*)GetDlgItem(IDC_LISTBOX1))->GetCurSel();
-
There is also this option... which is basically the smae thing except not MFC
Code:
GetDlgItem(hDialgBox, IDC_BUTTON1)->SetWindowText("Butto");
or
Code:
SetDlgItemText(hDialogBox, IDC_BUTTON1, "Button);
-
-
Quote:
Code:
GetDlgItem(hDialgBox, IDC_BUTTON1)->SetWindowText("Butto");
You what? :confused:
You need the GetDlgItemText and SetDlgItemText functions.
Although all this is moot unless we know whether you're using MFC or not...
-
Oops... my mistake...
I have gotten used to using MFC... it was just natural to put the "->SetWindowText()" in there
-
AAARGGGHHH!!!
EVIL EVIL EVIL! MFC!!! *gag* *ack* *choke*
Just wondering, but why do you use MFC? Nothing against you for it, just asking...
-
Lets see...
In the beginning I began with C++... just doing command line applications... nothing very interesting...
Then I was exposed to VB and Windows Programming... It kinda grew on me... soon after that I started looking into the Win32 API... and using some of the functions in VB... (CDAudio control, System Tray Icons, etc)
Then I took a class in school on VC++, which taught MFC... I wanted to use API, but we didnt... I never really go into windows programming in VC++ until about 6 months ago... when I first started obviously I had to use what I already knew, which was MFC and i used the API functions I already knew....
I guess I would say 4 months ago I guess I started learning more about the Win32 API...
Currently, I will only use API... I actually enjoy it much more than MFC... there is more satisfaction when you get things to work...
The reason why I put the "->SetWindowText()" things was because where I work... all GUI is done in MFC (and Stringray Controls: basically Enhanced MFC controls)... Kinda gets stuck in there sometimes...
But I am with you on the API thing... much better... helps you understand how things actually work...
For the people who like knowing how things work... and who want more satisfaction out of windows programming... use API and throw MFC out the window.
-
A little history lesson for ya...
-
Fair enough...
It's like a prostitute, MFC is quicker but not as satisfying...
-
-
-
Try this:)
Get "hBUTTON" text
PHP Code:
GetDlgItemText(hwnd,hBUTTON,GetWindowText(hwnd,GetDlgItem(hwnd,hBUTTON)+1);
Set "hBUTTON" text
PHP Code:
SetWindowText(hBUTTON,"GO ****");
I'm not sure if the 1st one right... I haven't touch computers for more than 2 weeks, and yet I'm only a beginner in VC++.
-
Wrong
Wrong, try THIS:
Get "hBUTTON" text
PHP Code:
char buffer[256]="";
GetWindowText(GetDlgItem(hwnd,hBUTTON),buffer,sizeof(buffer));
//Then use buffer. It holds the window (control)'s caption at
//the time the code executed.
Set "hBUTTON" text
PHP Code:
SetWindowText(GetDlgItem(hwnd,hBUTTON),"GO ****");