|
One last question.
I put together this:
void SetCheckbox(int nID, bool state)
{
CButton *pCB = (CButton *)GetDlgItem(nID);
if (pCB)
pCB->SetCheck(state);
delete pCB;
}
and so I call:
SetCheckbox(IDC_CHECK20, 1);
SetCheckbox(IDC_CHECK21, 0);
But when I compile, I get this error:
error C2664: 'GetDlgItem' : cannot convert parameter 1 from 'int' to 'struct HWND__ *'
The function GetDlgItem takes 2-variables, int nID and HWND *phWnd. I tried using null for the 2nd variable (phWnd) but it
wont work. How can I clean this up to work?
Please, any response you can give me will be greatly appreciated.
I have alot of check boxes and need to condense.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
The GetDlgItem function retrieves the handle of a control in the specified dialog box.
HWND GetDlgItem(
HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
);
Notice the above text from MSDN.
DanYELL wrote:
I tried using null for the 2nd variable
Don't use NULL for the 2nd variable:
(1) Because the HWND structure was supposed to be the first variable, hence your original error:
DanYELL wrote:
error C2664: 'GetDlgItem' : cannot convert parameter 1 from 'int' to 'struct HWND__ *'
(2) Because the HWND parameter in GetDlgItem is supposed to be the handle of the dialog that this dialog item is on. Try possibly, this , the word "this" referring to "the current dialog".
The simpler, though perhaps more unpopular/messier way would be to use UpdateData(), but not UpdateData(FALSE). The check boxes usually function pretty cool by themselves (i.e. checking an unchecking themselves when you click on them), but you're trying to control a partner check box. So, try something like:
<br />
void OnCheck20(void){<br />
UpdateData(TRUE);
<br />
if(m_Check20 == true){<br />
m_Check21 = false;<br />
UpdateData(FALSE);<br />
}<br />
else if(m_Check20 == false){
}<br />
}<br />
Write a similar function for the other check box. You just gotta use the UpdateData(TRUE) so you don't change all the other controls to their last updated state.
Danny
|
|
|
|
|
I've just sent by e-mail a small test VC project
showing what you need )
SkyWalker
|
|
|
|
|
if only one check box is to be checked, use radio buttons instead.
however, you don't test if the checkbox is effectively checked or not - because the event handler is called wether you check or uncheck it.
void CPage1::OnCheck20() {
UpdateData()
if (m_check20 == TRUE) {
m_check21 = FALSE;
UpdateData(FALSE);
}
}
void CPage1::OnCheck21() {
UpdateData()
if (m_check21 == TRUE) {
m_check20 = FALSE;
UpdateData(FALSE);
}
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
DanYELL wrote:
The problem is, when
this code is run, the UpdateData(FALSE) commands resets all of
the checkboxes that were at the top of the screen (m_check1 ...
m_check19).
Which is one of the many reasons to not use the function. See here for more.
DanYELL wrote:
How can I update just m_check20 and m_check21 without updating
the rest of the check boxes on that page?
Have a CButton member variable for each checkbox. Use the SetCheck() and GetCheck() methods.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
You could also use the CheckDlgButton function.
<br />
CheckDlgButton(IDC_CHECK20, 1);<br />
CheckDlgButton(IDC_CHECK21, 0);<br />
He is smart. He will make our Windows go.
|
|
|
|
|
hi
I created a shell extension DLL (MFC). But even though I've included manifest file, the DLL's dialogs are not themed. Can anyone help please ?
regards
hari
Hari Krishnan
|
|
|
|
|
From MSDN:
"That manifest file must be named correctly (<your .exe="" name="">.manifest) and must be in the same directory as the .exe file for your application to take on the correct appearance"
SkyWalker
|
|
|
|
|
thanks for the reply, but..
manifest file is included as a resource, not as a seperate file.
Yes, i've tried using it as a seperate file, but it does not work. (plz note, I've other exes that work correctly. The problem occurs only if I use the resource in this dll)
Hari Krishnan
|
|
|
|
|
pranavamhari wrote:
Yes, i've tried using it as a seperate file, but it does not work. (plz note, I've other exes that work correctly. The problem occurs only if I use the resource in this dll)
these article may help:-
MANUALLY EMBEDDING MANIFEST FILE:-
http://www.codeproject.com/w2k/makexp.asp[^]
AUTOMATE MANIFEST FILE LINKING:-
http://www.codeproject.com/macro/ManifestMacro.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi Friend,
I am working on application developement and i have to enhance the speed of existing application. So i need to know the time taken by the application. Is there any programmatical way to find out the time taken by application.
Thanks
|
|
|
|
|
An actual profiler would be your best bet, but you can use GetTickCount() to get reasonably close.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I haven't used the profiler in VS2005 but the profiler in VC++6.0 is useful.
It shows the number of times a function was called in addition to the time spent there.
You can also use it to get an idea of which sections of your code are used under various circumstances.
Elaine
The tigress is here
|
|
|
|
|
Trollslayer wrote:
...the profiler in VC++6.0 is...
...located where?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
It's not in all editions (Professional and Enterprise, IIRC) - if you have it it'll be on the Build menu, right at the bottom. You need to enable profiling in the link options first.
|
|
|
|
|
Thanks. That menu option was not initially enabled because I was missing the following registry value:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevStudio\6.0\General\ProfilerInstalled
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevStudio\6.0\General\ProfilerInstalled
What Key or Value, I have to enter here to Enable Profiler
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
The key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevStudio\6.0\General and the value is ProfilerInstalled, which is set to 1.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevStudio\6.0\General and the value is ProfilerInstalled, which is set to 1.
Thanks For Information!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Can some please explain me the reason why values added in combobox are shown in hexa in the ".rc" i.e. the resource file while strings/caption associated it with other controls like Button, EditBox have ASCI values.
Any Logic ?
Regards
|
|
|
|
|
I wanted to get Color of a Dialog and set it to a toolbar. I am able to get the color of dialog.
a) How can I get color of other controls.
b) Is there some generic way where I can get background color of control. c) What if the color is gradient.
d) and wat about if it has bitmap as its background.
One other thing,
e) How can then I set a background color of a toolbar, to be more specific.
I have achieved to change bg color of static label but I am, not able to do it with toolbar. Any help ?
Regards,
|
|
|
|
|
|
Hi,
In my app i need do draw a icon on a specific place(each time
on a different place).
I added the icon to my resources(it's ID is IDI_Target_ICON)
and I'm using this code(I want to display the targets on a thread) :
UINT ShowTargetsThread(LPVOID lpvoid)
{
TargetsViewDlg *dlg = (TargetsViewDlg *)lpvoid;
CDC *dc;
CRect rect;
int nX = 0 , nY = 0;
HICON hIcon;
HBRUSH hBrush = CreateSolidBrush(RGB(0, 0, 0));
dc = dlg->m_TargetsViewBMP.GetDC();
dlg->m_TargetsViewBMP.GetClientRect(&rect);
for(int i = 0 ; i < 20 ; i++)
{
nX = (rect.right - rect.left) / 2;
nY = rect.bottom - (i * 10);
DrawIconEx((HDC)dc, nX , nY , hIcon, 16, 16, 0, (HBRUSH)hBrush, DI_IMAGE);
Sleep(200);
}
return 1;
}
The problem is I don't know how to load the icon.
Anyone?
Regards,
Eli
|
|
|
|
|
HICON hYourIcon =
LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_YOUR_ICON))
SkyWalker
|
|
|
|
|
how can i get a color of control. What is its a radient color. What is returned, a HBRUSH or COLORREF ? ... Can some1 guide me ??
|
|
|
|