|
I have 2 file list window which are "1FileListCtrl" and "2FileListCtrl"
and I have 2 radio. If I check radio one, I expect 2FileListCtrl window is disable but it is not disable. Do you know how to solve my problem?
These below is my code (when I check radio one)
void CTestView::OnKeyfileRadio() <br />
{<br />
UpdateData(TRUE);<br />
if (m_keySrc == 0) {<br />
1FileListCtrl.EnableWindow(TRUE);<br />
2FileListCtrl.EnableWindow(FALSE);<br />
}<br />
UpdateData(FALSE);<br />
}
This is my picture problem
http://www.geocities.com/foruonlyna/1.JPG
|
|
|
|
|
You code seems to be ok. So you could check if your call to UpdateData(TRUE) is succesfull. And are you sure that 2FileListCtrl is connected to the window you expect it to be? Or do you have another handler for your 2nd radio box, which possibly re-enables your window?
|
|
|
|
|
m_keySrc is your problem. solution:
ooosawaddee3 wrote:
//if (m_keySrc == 0) {
1FileListCtrl.EnableWindow(TRUE);
2FileListCtrl.EnableWindow(FALSE);
//}
|
|
|
|
|
Lazy programmer is looking for way to automate removal of unused code from my MFC VC++ files. Not looking for code beautifier / formater - my code is beyond help here! Willing to build my own but have a little experience in this field. Any constructive suggestions welcomed. Thanks
Vaclav
|
|
|
|
|
Numega BoundChecker comes with "TrueCoverage" and TrueTime.
Both tools pretty good at detecting possibly dead code....
As far as really automated way I don't think so.... Function may be called on some very rare circumstances.
Unless you have very trivial case when function never called from anywhrere, then may be U can use VC parser to parse source, load functions into own hash table, and exclude all messages...
|
|
|
|
|
Hi All,
I wanted to make GUI windows for a console project written that is in C. So I created a simple MFC Dialog Box Application and included all the console project's source files, header files and the library files in to the workspace and called the main(...) function of the console project on the click of a button by passing the command line arguments with it.
The actual C console project, when run in Microsoft Development Editor in both debug as well as release mode, runs perfectly.
If I run the MFC project by pressing F5 in debug mode, it runs well but causes problem when i run the debug EXE from windows explorer. It also crashes when i run it in release mode either by pressing F5, Ctrl F5 or directly run the release EXE from windows explorer.
The problem when i debugged the release mode was that at a certain point, one malloc was returning NULL despite the fact that I have enough memory (256MB) with me.
The malloc is being called from the well running C project file. The same malloc call returns good values for 6 times but returns NULL for the seventh call when i try to allocate just 13 bytes. The problem is not the memory shortage but as i think may be the linking of the C project in MFC environment.
Any help is welcomed...
Deepak Gupta.
Have a Good Day!!!
|
|
|
|
|
Dear friends,
I developed an out-of-proc COM component i.e it is an exe that exposes interface. The clients talk with this component via the interfaces it expose.
Now i want this out-of-proc server to be able to call back its client, i.e i want to fire events from this component. Can any one tell me that how can i do so?? I would be glad if you point me out some sample application.
|
|
|
|
|
i need a functiont that will dial a telephone number or IP address, but i need it to be simple like some kind of DOS command or something like that, my other question is what code can i include to make my password apear like "***" instead of 123, thanks
|
|
|
|
|
There is a check box named 'Password' in edit control, which would help you do that. my previous reply was for c#, sorry
Cheers,
Kannan
|
|
|
|
|
Use RasDial() for dialing a telephone number.
A. Riazi
|
|
|
|
|
let say i had created a thread by
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadFunc, // thread function
&lpVoid // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
with thread function
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpVoid)
{//let say again
while(1){
if(int a == 1)
m_result += " success";
}
return 0;
}
i oso created an editbox with a Cstring variable m_result.
now, my question is how can i update the editbox through the m_result variable?
thks for all the advice and help
regards,
afender
|
|
|
|
|
You can pass dialog class's address as the parameter of the thread function and then through that pointer you can access variables and functions of your dialog class.
C.R.Naik
|
|
|
|
|
You can do it by passing dialog class's address as the parameter to the thread function and then access dialog class's variable through that pointer.
C.R.Naik
|
|
|
|
|
how can i pass the dialog class's address..as in how should i write on the third argument of the createThread()
sorry to trouble again
Regards
afender
|
|
|
|
|
Anonymous wrote:
on the third argument of the createThread()
If you're using MFC inside of the worker thread then call AfxBeginThread to start it. It's the only way you can make MFC objects to acquire correctly the TLS data they use.
rechi
|
|
|
|
|
Simply by putting second parameter of AfxBeginThread as "this". For further process...please refere following replies for this question.
C.R.Naik
|
|
|
|
|
hi
below are the code i had modified
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpvoid)
{
CProjectv1Dlg *myThis = (CProjectv1Dlg *)lpvoid;
while(1){
if( a == 0){
myThis->myThis = "read success";
myThis->UpdateData(FALSE);
}
}
}
now my problem lies on the myThis->UpdateData(FALSE), it seems i cannot directly use this function. Any other way to update the data?
thks again
afender
|
|
|
|
|
I supposed that ID of your dialog's Edit Box is IDC_EDIT_MYTHIS, then your problem can be solved by the following code :
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpvoid)
{
CProjectv1Dlg *myThis = (CProjectv1Dlg *)lpvoid;
while(1){
if( a == 0){
//myThis->myThis = "read success";
//myThis->UpdateData(FALSE);
::SetWindowText(::GetDlgItem(myThis->m_hWnd, IDC_EDIT_MYTHIS), "read success");
}
}
}
Welcome
C.R.Naik
|
|
|
|
|
hi
below are the code i had modified
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpvoid)
{
CProjectv1Dlg *myThis = (CProjectv1Dlg *)lpvoid;
while(1){
if( a == 0){
myThis->m_result = "read success";
myThis->UpdateData(FALSE);
}
}
}
now my problem lies on the myThis->UpdateData(FALSE), it seems i cannot directly use this function. Any other way to update the data?
thks again
afender
|
|
|
|
|
The problem should be that UpdateData is protected and can not be accessed from without the class. Thus you could add a public function to your dialog which calls UpdateData and changes the value of your member variable.
|
|
|
|
|
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpvoid) <br />
{<br />
CProjectv1Dlg *myThis = (CProjectv1Dlg *)lpvoid;<br />
while(1){<br />
if( a == 0){<br />
myThis->display(); <br />
}<br />
}<br />
}<br />
<br />
void CProjectv1Dlg::display()<br />
{<br />
UpdateData(FALSE);<br />
}
is this what u means?
regards
afender
|
|
|
|
|
(This post has been edited to correct a stupid mistake on my part. See later follow-up for more information.)
Never update a window directly from a worker thread. You should also avoid using SendMessage from a worker thread to a window. Instead, use PostMessage and use a user defined message (WM_USER + x.)
In your example, you'll either need to pass a discrete value, which the dialog will then use to obtain the string itself and pass that as one of the parameters of the user message. Or put a critical section around any reading/writing of m_result.
|
|
|
|
|
i still not quite understand on how to do it.
ok, let say i put the PostThreadMessage() in the worker thread as follow
unsigned long __stdcall CProjectv1Dlg::ThreadFunc(void* lpVoid)
{
CProjectv1Dlg *myThis = (CProjectv1Dlg *)lpVoid;
while(1){
if(count == 0){
m_result += "success";
PostThreadMessage(myThis->TID, WM_USER + 0x10, 0, 0);
}
}
return 0;
}
where i use the
TID = GetCurrentThreadId();
so now the question is,
let say i want to update the edit box, how to determine the WM_USER + x? or just simply put a value in the specific range.
regards
afender
|
|
|
|
|
Unfortunately, I mixed two solutions together and blundered. You shouldn't use PostThreadMessage, but rather call the PostMessage of the dialog from the thread. (i.e. mythis->PostMessage(WM_USER + 0x10....)
The value for your user message can be anything, just make sure it's unique (I've made that mistake before.)
You then need to make a custom handler for the Dialog for that specific user message. To make the dialog flexible, in the past I've passed and IDS_ define as the WPARAM (or LPARAM) and then the message handler simply loads that string and updates the edit control. (If you know that only the thread will be setting m_result, then you can get away without a critical section, but that may come back to haunt you someday.)
Here's a link to help explain that.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_MFCNOTES_TN006.asp[^]
|
|
|
|
|
hei, it works
Thks for the help, really appreciate it!!
regards,
afender
|
|
|
|