|
Hello,
is there any way to loop over the dialog box and set new state of an CCheckBox?
In my example i have an litle dialog with 24 checkboxes + one for all!
Ok, i like when i check this one ,lets say IDC_CHECK_ALL, all other check boxes
should be checked
Its very simple dialog box, 24 + 1 Check boxes and two buttons!
I think on CDialog::NextDlgCtrl() but how to use it and is that the right function for that?
if(IsDialogChecked(IDC_CHECK_ALL))
{
}
thanks in advance
break;
|
|
|
|
|
|
Hello Ravi,
thanks very mutch, i try this!
regards
break;
|
|
|
|
|
My suggestion is that you create a container for your checkbox objects and create them dynamically. You can use std::vector< CCheckBox* > .
This way you can iterate through your container instead of using calls like GetDlgItem and NextDlgCtrl which should be avoided. See here[^] for reasons why.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Try setting all of the resource IDs for the checkboxes to be sequential, and then making a loop that iterates through all the ID's.
Write a function that contains the loop and accepts a bool that indicates whether or not you're checking or un-checking the boxes. Using EnumChildWindows will also work, but if the dialog contains more than just checkboxes, you'll be wasting processing time.
There's no reason to over-engineer something like this.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
OK, here's the situation: Inherit Code. Shown menu item (an existing form) that needs to have a new control added to it so a user can create a new directory to store their files in. This previously existing form allows me to either cancel or hit OK. No problem. So I naively add an edit control and recompile the code. The form displays and I press cancel(or OK, whatever). Assertion error. So I go looking.
I discover I'm having a problem where the resource files I create are not creating unique identifiers for each control. I've ruled out the logic behind any of the existing code; because all I have to do it add the control to see these errors.
For instance, my resource.h file contains many, many, many entries. Some of the values for the entries have the same numerical constants( See 1016, 1017, & 1018):
<br />
#define IDC_DTC_CNT_LBL 1008<br />
#define IDC_DTC_CNT_VALUE 1009<br />
#define IDC_CRNT_DTC 1010<br />
#define IDC_PNDG_BUTTON 1011<br />
#define IDC_FREEZE_FRAME 1012<br />
#define IDC_Meter 1015<br />
#define IDC_COMBO1 1016<br />
#define IDC_SPECIFIC_CODE_COMBO 1016<br />
#define IDC_TRIGGER_COMBO 1016<br />
#define IDC_COMBO_CATEGORY 1016<br />
#define IDC_CMBO_APPLICATION 1016<br />
#define IDC_COMBO3 1017<br />
#define IDC_COMBO_DOWN 1017<br />
#define IDC_MIN_COMBO 1017<br />
#define IDC_COMBO2 1018<br />
#define IDC_COMBO_APPLICATION 1018<br />
#define IDC_CMBO_CATEGORY 1018<br />
#define IDC_DataList 1019<br />
#define IDC_O2_LIST 1021<br />
#define IDC_BUTTON1 1022<br />
#define IDC_GET_DTC 1022<br />
#define IDC_BTN_ADD 1022<br />
#define IDC_BTN_ITEMCHECK 1022<br />
#define IDC_BUTTON2 1023<br />
#define IDC_BTN_REMOVE 1023<br />
#define IDC_BUTTON3 1024<br />
#define IDC_BTN_REMOVEALL 1024<br />
#define IDC_METER_UP 1026<br />
#define IDC_METER_DOWN 1027<br />
So, the simple answer is to clean it up, right? Not so fast, quick draw. I did that( renumber them start from 100, then starting at 1000 - for their appropriate resource-section.) and now the form isn't even displayed before the assertion errors happen. I click the menu-item and BAM - ASSERTion city.
It seems to me that there are cross-references to other resources in other resource files.
Are there any tools to clean up resource issues like this with VS? Now, here's the kicker: I'm using eVC 4.0 SP4. Yeah, me.
Props to those who reply.
|
|
|
|
|
search for ResOrg here on CP, it's a nice tool made by Anna that helps cleaning up the resources.
|
|
|
|
|
Thanks! I'm checking it out now.
|
|
|
|
|
Hi,
I have a service written in C++. When I get SERVICE_CONTROL_STOP command, I want to check certain condition and if that condition is false then return an error and not stop the service.
In the service control handler function (registered by RegisterServiceCtrlHandler), I have a code which looks as follows:
void service_ctrl(DWORD dwCtrlCode)
{
...
switch(dwCtrlCode)
{
....
case SERVICE_CONTROL_STOP:
if ( CanStop() == FALSE )
{
// stop not allowed.
ssStatus.dwCurrentState = SERVICE_RUNNING;
ssStatus.dwWin32ExitCode = NO_ERROR;
ssStatus.dwCheckPoint = 0;
if (!(fResult = SetServiceStatus(
sshStatusHandle, // service reference handle
&ssStatus))) { // SERVICE_STATUS structure
// LOG SOME ERROR
}
}
else
{
// stop allowed.
....
}
break;
}
...
}
The problem is:
When I stop the service, by running "net stop MyService", it displays "service could not be stopped", the service status remains "started" and this is great.
But when I run "net stop MyService" again, it displays "The service could not be controlled in its present state" and the service status becomes blank.
How should I decline service stop request properly?
|
|
|
|
|
According to the docs:
SERVICE_CONTROL_STOP
Notifies a service that it should stop.
If a service accepts this control code, it must stop upon receipt. After the SCM sends this
control code, it does not send other control codes.
Windows XP/2000: If the service returns NO_ERROR and continues to run, it continues to receive
control codes. This behavior changed starting with Windows Server 2003 and Windows XP SP2.
|
|
|
|
|
i want to extract the pixels 320x320 from the webcam browser on monitor screen and put into the array. Anyone can help me in this problem about the source code or related information?
love-peace-joy
|
|
|
|
|
What's the webcam browser?
There's APIs available for video capture that may give you better results than trying to
scrape the screen.
|
|
|
|
|
Hi All,
I have a dll in vc++( It shows one dialog with some static box and list control) .
Case 1. If i create this by statically linked in project settings and keep mantain it's default settings( with out support unicode)
then it used properly in my project ( Give the desired output)
Case 2. If i create it unicode compatiable by using all unicode liberary in project settings then As i use it into my project and build , my project buid properly but terminate as i execute it. ( My project is also unicode compatiable)
Why it is happening , is there any other way to build the unicode compatiable dll, or any other type of setting other then exe settings.
Thanks
SNAV
|
|
|
|
|
singh_nav wrote: my project buid properly but terminate as i execute
Does this mean , it is crashing ?
Have you tried to debug it ?
|
|
|
|
|
yes i tried to debug it , But it crash before it comes in the App class Init function .
ND
|
|
|
|
|
I have a dll written in C where in the function parameter does not contain any device context.
I want to use that dll to draw in a view or dialog in VC++.
I am able to link the dll and the function returns the correct parameter value but no drawing appears
Can someone help please
mk
|
|
|
|
|
, code ?
|
|
|
|
|
mk79 wrote: C where in the function parameter does not contain any device context
And how do you get your Device Context for drawing?
(i.e. post code please...)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Can you show snippet code
|
|
|
|
|
Hi
How can we find out the difference between dates.Is there any method to find that .please kindely help me.
#sanroop#
|
|
|
|
|
Have you tried using class COleDateTime ,COleDateTimeSpan ?
|
|
|
|
|
Iam very thankful for your raply.I saw all methods in COleDateTime,COleDateTimeSpan here my problem is to find the difference between current date and any otherdate what ever i give.
#sanroop#
|
|
|
|
|
|
Sanroop wrote: ...my problem is to find the difference between current date and any otherdate what ever i give.
Which is what COleDateTimeSpan does, assuming you are using MFC. Otherwise, check out difftime() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
What format are your dates in?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|