|
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
|
|
|
|
|
I'd like to create a class derived from CComboBox which replaces the normal dropdown with a window containing a calendar control plus a few clickable areas. My first instinct is to create a very basic window which has the calendar as a child window and paints these clickable areas itself. When the dropdown arrow is clicked we create and show this window and somehow suppress the normal dropdown.
Is this the 'correct' way to tackle this? After trying it out I'm having a number of problems The most glaring is that when the dropdown window is displayed the frame of the hosting dialog changes, ruining the illusion that the dropdown is part of the combobox. I think this may be because the dropdown window is a WS_POPUP (to avoid being restricted to the CCombobox client area). When the dropdown is active, the dialog isn't, causing the frame to be redrawn. That's my guess anyway.
There are numerous other problems which need to be tackled: how to handle focus, mouse capture etc; how to suppress the normal dropdown list; how to handle events such as the Windows button being pressed (i.e. how to automatically cancel the dropdown). These can probably wait for now though
Anyone have any solid suggestions about how to create this custom dropdown? Any good links, blogs, books, or articles?
modified on Tuesday, April 13, 2010 3:48 AM
|
|
|
|
|
You might want to look at my article: Generic Picker Dropdown Control[^] or the article that I drew inspiration from: Office 97 style Colour Picker control[^]
Both of these will let you have a combo-box-like control, which then pops up another control You should be able to adapt them to show a calendar control instead.
I hope that helps,
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Nice article, but it doesn't address the specific problem I described. I ran your demo app and sure enough the frame of the dialog changes to reflect that it is no longer active or has focus, or whatever the change of frame painting means . Compare this to the Date Time Picker control (which is loosely what I'm trying to mimic): when its dropdown window is shown it doesn't cause any change to the dialog, and feels integrated with the rest of the control. It's a minor detail, but it's one which makes me think my basic approach is wrong somehow.
|
|
|
|
|
Thanks - you may have a point about my control! Nice catch.
Sorry it didn't help you however.
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Try creating your "dropdown" invisible and then show it with ShowWindow(SW_SHOWNOACTIVATE)[^], maybe that will help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
No dice.
After some playing around it seems as though setting the focus is what triggers the repainting of the dialog's frame. If the dropdown is created as a child (of the combobox), it doesn't redraw to show loss of focus. But the dropdown can't be a child due to clipping. If it's a popup then it causes the frame to be painted differently when the focus switches, which is what I was hoping to avoid.
Catch 22 for the time being. But this must be a very solveable problem...
|
|
|
|
|
Where does the focus go then? I guess you are not moving the focus to your popup ...umm... "explicitly". Maybe try removing the WS_TABSTOP style from controls on the popped-up window or somesuch... is your popup maybe a dialog? If yes then it probably places the focus onto whatever comes first on it that can receive the focus automatically, you can avoid that by returning FALSE from OnInitDialog[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi all..
I'm currently capturing screenshots and I want to save the images as files..
did manage to do it, but in .bmp format
I would like to know if there is a method to directly save the image as .jpg OR is there a possibility of converting the .bmp file to .jpg
'm coding in win32, using VS-2008
look forward to ur replies..
thank yu
|
|
|
|
|
you can use
System.Drawing.Bitmap class to do the conversations.
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: System.Drawing.Bitma
Which MFC class is that?
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: Which MFC class is that?
I believe it exists in MFC (M y F riend C #) framework.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
System.Drawing.Bitmap class exists in .net framework he can add the reference and use that class in win32 as managed c++ .
|
|
|
|
|
Also painters and decorators exist and you may add their phone numbers to the header files.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
ATL/MFC provides the CImage class (see, for instance [^]).
You may also use directly GDI+ Image class [^].
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
is there any windows event which tell to the application thatthere is date change ?
Thanks.
|
|
|
|
|
You might look into the WM_TIMECHANGE message.
Another option would be to set up a timer to fire every minute. Keep track of the date each time the timer fires.
"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
|
|
|
|