|
I want to dynamically change my dialog box. For example, if I click a check box I want text to appear or diappear, depending on the value.
Danny
|
|
|
|
|
Where is this text that you want to appear or diappear?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I might as well tell you that you are going to have to be bit more specific with your question before you will get an answer. otherwise the only thing you are going to get is: Handle the click event of the checkbox. In the handler if(checkbox.GetCheck()) show text else hide text.....
|
|
|
|
|
Sorry, I had thought I wrote it well. I meant, when I click a check box I have a static text box right next to it that I want to display either an empty string, if the check box is false, or a message, if the text box is true. I have already created member variables for the check box and the static text box.
Danny
|
|
|
|
|
In that case you could do something like:
if(checkbox.GetCheck())
textbox.SetWindowText("Some text");
else
textbox.SetWindowText("");
|
|
|
|
|
Anon E. Mouse wrote:
if(checkbox.GetCheck())
Be specific. CButton::GetCheck() is not a boolean function. If you only want to set text when the state is checked, specifically check for it:
if (checkbox.GetCheck() == BST_CHECKED)
textbox.SetWindowText("Some text");
else if (checkbox.GetCheck() == BST_UNCHECKED)
textbox.SetWindowText(""); Otherwise, the button may later get changed to a three-state check box and be in an indeterminate state.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks for clarifying that. That is correct.
|
|
|
|
|
DavidCrow wrote:
if (checkbox.GetCheck() == BST_CHECKED) textbox.SetWindowText("Some text");else if (checkbox.GetCheck() == BST_UNCHECKED) textbox.SetWindowText("");
Thanks, but that leaves the question, what do I use in place of 'checkbox' when I do 'checkbox.GetCheck()'? The member variable shouldn't work and I tried the ID.
Danny
|
|
|
|
|
bugDanny wrote:
what do I use in place of 'checkbox' when I do 'checkbox.GetCheck()'?
Whatever name you gave the member control variable.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
bugDanny wrote:
what do I use in place of 'checkbox' when I do 'checkbox.GetCheck()'?
Whatever name you gave the member control variable.
No, using the member veriable name doesn't work. I get the error "left of '.GetCheck' must have class/struct/union type. The same when trying to change the static text box.
Danny
|
|
|
|
|
checkbox should be a CButton , and textbox should be a CStatic .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
checkbox should be a CButton, and textbox should be a CStatic.
I suppose I really was too vague in the first place. The above suggestions do not work because I never hand created a CButton or CStatic for these controls. checkbox should be the name of an instantiated CButton and textbox should be name of an instantiated CStatic, but since I never instantiated these I can't do that. I only put a static text box control onto the dialog and a checkbox control and set the ID and member variable names. Shouldn't there be a simpler way, like a refresh() function (I checked help and the refresh commands were for other languages. Maybe it's named something else for C++)
Danny
|
|
|
|
|
If you don't create member variables for the controls, how do you expect to interact with them? You can't just put a control on the dialog and expect it to know what to do.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
bugDanny wrote:
I only put a static text box control onto the dialog and a checkbox control and set the ID and member variable names.
I did create a member variable for the controls, as I noted above.
DavidCrow wrote:
checkbox should be a CButton, and textbox should be a CStatic.
However, I never instantiated a CButton (i.e. I never called the CButton constructor), unless Visual Studio automatically does that for me somewhere. In any event, putting the member variable name in front of '.GetCheck' does not work. If the member variable name was an instantiation of CButton it would. I get an error if I try to use either the member variable name in front of '.GetCheck' or the ID. Those don't work.
Danny
|
|
|
|
|
I finally did find the command to change text. It's a dialog item, so you use SetDlgItemText(int ID, string str), but the problem was and is that the dialog box doesn't update when the state changes. That is, the static text box doesn't display the new string I set the text to)
Danny
|
|
|
|
|
I need to check the activity of the user, to detect when the user is outa here. I need it to set away mode in software. But I don't want to hook all messages like spy software. is there any way to detect the ser activity ? Screen saevr detection is not an good way.
Pavel Sokolov
http://crea70r.photosight.ru
|
|
|
|
|
How about GetLastInputInfo() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It's very good, but "Windows 95/98/Me: Unsupported."
I understand that support of these systems is almost stopped, but my customers have all range of systems. Maybe I will emulate this function for Win9X - Anyway thank you very much.
Pavel Sokolov
|
|
|
|
|
Pavel Sokolov wrote:
Maybe I will emulate this function for Win9X
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thank you! Just found it
Pavel Sokolov
|
|
|
|
|
I read that article and he puts the hook handler handles and counter into shared memory:
#pragma data_seg (".IdleUI") // any name you like
HHOOK g_hHookKbd = NULL;
HHOOK g_hHookMouse = NULL;
DWORD g_dwLastInputTick = 0;
#pragma data_seg ()
Why is that? Doesn't that mean that only one thread of a single process can use the hook handler in this DLL? Why aren't those data at least process-specific so multiple applications could have used the functions in the DLL? I recently made a mouse hook handler and I did NOT put anything like this in the shared data segment and it works fine. Do you think that was something specific for the Windows 9X support?
|
|
|
|
|
Blake Miller wrote:
Why aren't those data at least process-specific so multiple applications could have used the functions in the DLL?
That would defeat the purpose of checking for idleness. If these variables were not marked as shared, each process that used the DLL would get its own copy of the variables, thus idle in one process might not be idle in another process.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a dialog which contains a CListCtrl to dislplay some information.
two cwinthreads from other dlg keep updating the data of the CListCtrl.
the CListCtrl's handle is passed to the threads and there is a Shared CriticalSection among these 3 objects.
when i close the dlg, i want to set a flg to inform the two threads that the list is destroyed. so i call in the exit event of the dlg:
lock.Lock();
destroyFlg = true; // the threads will check this flg before access the list
//and access to the list is protected by lock & unlock
lock.UnLock();
what happend is that , the dlg is hung. i traced and find it hung at lock.Lock();
there is only one crictical section and i am sure i have paired each lock() with a unlock(). why this still happend?
Some one knows please help me. thanx a lot.
|
|
|
|
|
a_du wrote:
two cwinthreads from other dlg keep updating the data of the CListCtrl.
You can avoid a whole lot of problems by simply having these other two threads post a message back to the main thread (the one that actually owns the GUI). Locking and synchronizing are a headache if not done 100% correctly.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Consider using a wrapper class to lock your object.
See following code:
http://code.axter.com/sync_ptr.h
The above wrapper class will automatically lock and unlock your object, so you don't have to worry about forgetting.
|
|
|
|