|
b-rad311 wrote: while (sscanf(incoming_line, "%s", string_out )==1)
You cannot use a CString object in this capacity.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi David,
Should I use "const char*" instead?
|
|
|
|
|
If you did, then how would scanf() be able to change its contents?
Since you are using MFC, have a look at CStringT::Tokenize() or AfxExtractSubString() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi friend,
How to change static text color and backgroung color, please help me.
Thanks and Regards,
D.Manivelan
|
|
|
|
|
Member 4482742 wrote: How to change static text color and backgroung color...
Are you referring to WM_CTLCOLOR or one of its variants?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I'am hooking the sendto function and i would like to log names of every DLL/prog which call it.
How can i retrieve the names of the DLLs which call to the sendto hooked function ?
|
|
|
|
|
You could insert GetModuleFileName(NULL, ..) into your hook function
virtual void BeHappy() = 0;
|
|
|
|
|
I already made a try with this method but it id not work.
The returned name's module is the one of the *.EXE which loaded the DLL, but not the DLL's name itlsef(DLL which makes calls).
|
|
|
|
|
Call GetModuleFileName() with the HINSTANCE that was passed to your DllMain() function. That said, I do not believe GetModuleFileName() is what you are after.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello
Question : Differentiate static and extern ? If the data is static, how can you access that data in another file ?
My answer is :
The static keyword allows a variable to maintain its value among different function calls. Extern says the variable, or function, is defined outside this source file.
main.h
--------
#include <>
static int x;
main.c
--------
#include "main.h"
int main(void) {
printf("\n x is %d", x);
return 0;
}
My answer is sufficient or partially or wrong ...? Give me an advise ?
Thanking you.
|
|
|
|
|
its partially correct.
'static' has multiple meanings. you've mentioned one, but there is another meaning that is more closely related to 'extern'.
|
|
|
|
|
Could you elaborate it , please?
|
|
|
|
|
|
Hi Created a CRectTracker for a button,it is resizable. i dont want to Resize option but i want click and move the button within the dialog.
CRectTracker(rect,CRectTracker::dottedLine | CRectTracker::hatchedBorder );
CRectTracker::resizeOutside like is there NoResize option
|
|
|
|
|
It would not be resizable,
when you will call its CRectTrcker::Draw(..) only
Just modify CYourDialog::OnPaint() function
virtual void BeHappy() = 0;
|
|
|
|
|
My application has several MFC threads running concurrently; these threads process their messages by using Peek Message.
I want to know queue size in each thread (i.e. pending messages in thread queue).Is there any API that can tell me the message count or pending message count for each thread.?
If there is no such an API, Is there any method to get message count at process level.?
ajmalsiddiqui
|
|
|
|
|
Would GetQueueStatus() help?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks for the response , but i think this would not because this function returns the type of messages in the queue, not message count or queue length.
I wan to get number of messages in queue or number of pending messages in queue.
ajmalsiddiqui
|
|
|
|
|
ajmalsiddiqi wrote: Thanks for the response , but i think this would not because this function returns the type of messages in the queue, not message count or queue length.
It returns the number of the type you request.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
As far as I know you shouldn't run into any problems because the queue is too small. It's one of those questions that the very fact it's asked makes me wonder if your design is "correct". Can I ask why you need to know?
Steve
|
|
|
|
|
Thanks, I am little bit cofused by your reply and unable to understand.There is no issue I just want to add some functionality in my application threads, I just want to check queue length,In my application there are 15 threads one of them is main thread(Controller Thread).All threads are posting theire different customized message and some data in WPARAM/LPARAM using using PostThreadMessage function.
Now the controller thread receive all these messages using PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE)from thread mesage queue in its Run method.
// code snap shot
Controller::Run()
{
While(1)
{
while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE))
{
switch(pmsg ->message)
{
case MSG_RE_START:
// log here pending messages in queue
//do some functionality
case MSG_RE_StOP:
// log here pending messages in queue
//do some functionality
}
PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE);
}
}
}
So when I receive one message I wan to log the pending messages which are still in queue and will be processed in next iteration means in call of PeekMessage.
After Processing one Message I remove it from Thread queue using PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE)
So can I get the queue status , how many number of messages are in thread queue or queue length.?
ajmalsiddiqui
|
|
|
|
|
There are a number of issues here.
The first problem you may encounter is related to the posting of thread messages. Does the main thread have any UI? Messages boxes, dialogs, anything like that? If so you may encounter the problem described here[^]. The solution (posting the messages to a hidden window instead) is also described.
The next problem is that the main thread will sometimes throw away messages:
Controller::Run()
{
While(1)
{
while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE))
{
switch(pmsg ->message)
{
case MSG_RE_START:
case MSG_RE_StOP:
}
}
PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE);
}
}
If there are no messages in the queue at point (1) but there is at point (2) the message is simply discarded.
Another issue is that the main thread is constantly spinning in a busy loop doing nothing, degrading system performance.
Also you simply discard all messages, even ones that don't belong to you. You should dispatch them.
Also, even if your code was even close to working (which it's not) how do you know all the messages in the queue are yours?
Steve
|
|
|
|
|
There is no UI thread all are worker threads.This was not the exact code , the exact code is running well there is no issue in the application.I just write the scenrio of my requirment.
1.If there is message in the queue it will be processed and then will be removed.So there is need little correction is code:
PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE); // -(2) is inside the switch, not out of the inner while loop.
while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE))
{
switch(pmsg ->message)
{
case MSG_RE_START:
break;
case MSG_RE_STOP:
break;
case MSG_RE_DATA:
break;
}
PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE);
}
2.The main thread is not constantly spinning in a busy loop, becasue it waits on some events when exits from the inner loop.I did not mention, So leave it
3. Leave this, assume that the application is running not closing.
I just want to know that How can i get the pending number of messages in queue , for example when i receive MSG_RE_DATA message,How many number of messages MSG_RE_DATA are pending.
ajmalsiddiqui
|
|
|
|
|
ajmalsiddiqi wrote: while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE)) // -(1)
{
switch(pmsg ->message)
{
case MSG_RE_START:
// log here pending messages in queue
//do some functionality
break;
case MSG_RE_STOP:
// log here pending messages in queue
//do some functionality
break;
case MSG_RE_DATA:
// get number of pending messages
//Process data
break;
}
PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE); // -(2)
}
In this code the PeekMessage is not "inside the switch", it's in the while . Match up the brackets in the code you posted.
Steve
|
|
|
|
|
it must be inside the inner loop and out of the switch.
ajmalsiddiqui
|
|
|
|