am very new to MFC .
what i actually did ,i want explain you .
see i have different class UI cprogress here i am trying to update the progress bar according to some work is going on in back ground . this i did by creating thread in Cprogress class itself.in cprogress class m calling the core repair class, in repair class am sending the user define message for updating the progress ctl.when i want to cancel it am suspending the thread and trying to display the massageBox its appearing in inactive form it wont get exit on 1 click.the cancel event is in cprogress class it self.am used the postmessage(wm_destroy,0,0) to destroy the all the controls
This is how you have to implement some kind of parallel task on a thread with progressbar and cancel button: You setup the thread and start it to do its work. The worker thread posts progress updates to your gui by sending WM_USER+XXX message and an int parameter that is the progress, you should use PostMessage() and not SendMessage() to prevent your thread from waiting for your window to process the WM_USER+XXX message that sets the state of the progressbar. If you want to cancel the task from your gui thread then you should set a cancel flag for your worker thread and then you should poll this flag from your worker thread and stop doing the work if its set. Before exiting your worker thread you should send a WM_USER+YYY message to the gui thread indicating that the work has been cancelled.
i place the massage box in if(condition) this massage box getting inactive state.once i click the cancel the thread will suspended state if its true then i have flag and resume thread to release the memory and to finish the thread .every thing is working fine but the problem is with the message box not getting close with one click i dont know what do please help me out
Well, if you did what I recommended then I dont understand why is your code full of with suspendthread and resumethread, moreover this code isn't enough for us to point out whats wrong with your code, we need the surroundings of this messagebox code plus the codepiece from the thread that triggers this messagebox. If you have a modal messagebox in your program implemented correctly then it can become inactive only if the activation goes to the window of another application.
Another sidenote if you are using MFC: If you create gui elements (windows, etc..) from another thread its a problem because MFC installs hooks on newly created gui stuff and registers this-and-that to its internal structures that are not thread safe and you can cause all kind of diseases!
Then is_from_keyboard() below is better suited. It includes punctuation , spaces etc.
int is_from_keyboard(int ch)
if ( ch>31 && ch<128) return1;
cout<<"The ASCII character -> "<<ch<<" ("<<(int)ch<<") <- is from the keyboard. \n\n";
cout<<"The ASCII character -> "<<ch<<" ("<<(int)ch<<") <- is NOT from the keyboard. \n\n";
i am having a combobox (created through resource), and through code, i am updating the combobox with a list. for example, i am filling with "Kir" and "K". if i use CB_SELECTSTRING to select "K", its always selecting "Kir".
if i use "Kj" in place of "K", then the selection between "Kir" and "Kj" is fine.
from msdn definition :
It selects the first list item, if any, that begins with the characters in the specified text.
I construct a CRange object and then call CRange's function get_shapeRange() to get a CShapeRange object.
but it triggers an exception. (but it's OK to call another function get_InlineShapes) I have no idea why it triggers an exception.
does anyone knows why? thanks.
By the way, I call this code in a keyboard hook function.
bool isRangeShape(__in CRange& oRange)
// I promise oRange is correct, because I can call
// like this oRange.get_InlineShapes()
// in word2010 it's ok,but in word2003 triggers an exception
// but corresponding VBA code works fun in word2003 (not fun, I'm sorry)// word2003 don't support this method, oh my god!!!
CShapeRange oShpRange = oRange.get_ShapeRange();
long lCount = oShpRange.get_Count();
if (lCount > 0)