|
please tell me how can i add HICON to items of tree control.what's the problem of my code?
CImageList m_imgList;
CWinApp* papp=AfxGetApp();
if(papp!=0) {
HICON hicon1,hicon2;
hicon1=papp->LoadIcon(IDI_ICON1);
hicon2=papp->LoadIcon(IDI_ICON2);
m_imgList.Add(hicon1);
m_imgList.Add(hicon2);
m_tree.SetImageList(&m_imgList,TVSIL_NORMAL);
HTREEITEM chapter;
chapter=m_tree.InsertItem("country",0,0);
m_tree.InsertItem("canada",1,1,chapter);
chapter=m_tree.InsertItem("person",0,0);
m_tree.InsertItem("sonya",1,1,chapter);}
|
|
|
|
|
Especially for all of you screaming my article doesn't deserve to be posted.
|
|
|
|
|
By the way, I could publish a Windows bug that will shock everyone's imagination.
Here it is.
Windows, any version. Application of any architecture: Dialog, MDI, SDI. Have any input control with cursor placed in the client's part (for instance, EDIT). Set input focus on that control. Now hold the breath......Whenever you open a menu in your program all timers in your application freeze while you walk through menus!!!
Let me rephrase it for more clarity: While hovering mouse cursor over menus, if you have any input control with cursor in the client part, and that control has the input focus all timers in your application will go nuts: they will suddenly start slowing down very fast, and in a few seconds stop completely.
I found this bug in September 2002 while working on my tooltips project. It really shocked me when i realized that i cannot use windows timer because of that, and i had to write my own timer thread, and simulate API functions SetTimer and KillTimer.
See, I already offered a solution even to this outrageous windows bug, which promotes my note far better in the position of an article than this bitmap bug article
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
Sounds like it would make for a good article.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
Indeed, what remains to be done then is to single out that timer thread from my tooltips project, and make it generic so it could be used as a timer manager. Of course I could do so, but how about non-C++ programmers? Ok, I actually might write a COM server just to implement that kind of timer manager, and then, for instance, VB developers won't have a choice but to use it, while C++ developers will surely want just to incorporate it into their code. Yet I see I good point in actually doing this, and publishing such article. Let’s see first what Microsoft defenders will come up with, if such read this article.
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
sheesh
come on now dont be shy
make ur point clearly
"even if my world is weird its my world" biz stuff about me
|
|
|
|
|
What's more to say here....
I tested it in VC++6 and 7 with MFC and without MFC (pure Windows API) with applications of type Dialog, SDI and MDI. The bug is there, always been, takes place with any menu: Main, context and system.
Just thinking about how many programmers out there over so many years relied on using windows timers couldn't even suspect that something so outrageous could be undermining reliability of their programs...
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
Well, I dont know what you are doing wrong, but definitely you are doing it wrong. I can assure you that it works very well.
You can have any menu open, hover around and yet still WM_TIMER messages will continue to arrive in your message queue.
Definitely you should review your code, or ask someone to do it for you.
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
Oh Really! Well, then specially for you, i've just spent 5 minutes to write a simple Dialog application to show you the problem. Review the code, please!!!
P.S. It is so small and simple that there's nothing there even to review!!!! It's just the bug!!!
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
Bwahahahahahahaha, ha.
Ok, now that I could (haha) stop laughing, let me comment on it:
a) you really want to use a windows timer with a 10 millisecond interval? And in the timer routine you format a string and set the text of a control (which by itself means sending some messages around) ??? Then you really should think about using something better suited to your needs (Timer API for example).
b) When I open the system menu as you suggested, then the timer behaves exactly as it is documented and as I would expect it.
MSDN says:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.
As you may notice, when you move your mouse around, even outside of the opened menu, the timer runs in expected intervals.
Maybe you should get back to reading the documentation.
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
a) When i change the timer to call WM_TIMER every 100 millisecons the timer pauses for me every 5 seconds. When i update text in that static control it doesn't take any feasible CPU time that could possibly effect the way the program works.
b) Did you at least read what it says on the dialog box: "hold over a menu item"? I've checked this example i just wrote on w2k and XP - all i have at the moment, and the bug was there! And it is nothing to do with priority: on many occasions i observed the timer keep slowing down till stopped completely - what priority is that???!!!
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
As for your a) - yes, naturally, this has to do with the caret (cursor) of the edit control which is controlled by, gasp, a timer. Obviously not a WM_TIMER so it fires correctly which causes some processing in the edit control, which in turn leads to delivering other low-priority messages (WM_TIMER, WM_PAINT, etc) to the message queue.
The b) - not all windows messages are guaranteed to be delivered and none is guaranteed to be delivered in time. Simple as that. Some messages are even aggregated (WM_PAINT) or suppressed when already in the message queue (WM_TIMER).
All that is fully documented.
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
From MSDN on WM_TIMER:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.
The fact is when it happens CPU is busy by 2% at most, and nothing else is happenning in the system.
Yet delays that occur to the timer are really huge ones, which means they cannot be a result of low/high priority set in the system. WM_PAINT is not sent only when the system is busy by 100%, which makes sense, since it is WM_PAINT is responsible for visual interface. WM_TIMER is not responsible for visual interface.
And the last, how do you explain that the timer keeps slowing down till it stops completely?
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
Chopper wrote:
The WM_TIMER message is a low-priority message. The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue.
Let me add a piece here which is implicitly documented:
The GetMessage and PeekMessage functions post this message only when no other higher-priority messages are in the thread's message queue and the thread associated with the message queue is processing the queue.
A menu is NOT processed directly by the thread which owns the message queue. But the message which processes the caret forces a switch to this thread, thus the message processing.
I could not observe that the timer stops but if it does, I am pretty sure its secret lies in the message queue processing mechanism and the caret timer handling.
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
A menu is NOT processed directly by the thread which owns the message queue. - how do you know that? Menu window is always created by the GUI thread of the application, and i presume it is processed the same way, by the same thread.
I am pretty sure its secret lies in the message queue processing mechanism and the caret timer handling.Exactly my point! I just used the word "bug" instead of "secret", to avoid hazy phrases
How i found the bug: I wrote a tooltips component to display a tooltip for menu items. For that i had to use windows timer. I couldn't understand why sometimes appearance of tooltips showed some weird glitches till i found the bug.
Another contradiction: If you keep moving the mouse cursor within rectangle of the same menu item the timer doesn't slow down! Just as you stop - the timer begins slowing down. How do you explain that?
Regards,
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
Chopper wrote:
I just used the word "bug" instead of "secret", to avoid hazy phrases
Windows has so many bugs that you can safely use other expressions to classify a "behavior"
Chopper wrote:
Another contradiction: If you keep moving the mouse cursor within rectangle of the same menu item the timer doesn't slow down! Just as you stop - the timer begins slowing down. How do you explain that?
A mouse message is a higher priority message which is pushed through to the message queue. When you stop, only the caret timer kicks in occasionally.
[dont force me to write an article about timers, I dont have time for it.]
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
Enough said
I believe we can continue standing still at our positions and believes. The program is available, and the problem is visible, it is tangible and ass-kicking.
I leave it to the judgement of other developers with less and more experience than mine to verdict on the situation.
Peace!
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|
|
You could call TrackMouseEvent with dwFlags set to TME_HOVER and wait for the WM_MOUSEHOVER message.
|
|
|
|
|
Bitmaps were originally drawn into memory from the bottom up to minimize collision with the video scan line, improving video memory transfer rates and partial image flicker problems.
While the video memory is being read out, the CPU is locked out from performing updates. If the two are going in lock-step, the CPU loses. This whole issue became moot with dual ported RAM, etc.
Therefore, they were also stored in memory from bottom to top, as this is most efficient.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
Geert Delmeiren wrote:
BTW, can someone explain me why "the first pixel" = the lower left pixel of the bitmap and not the upper left one as I should expect?
A BMP is stored binary that way, the bottom row first, the top row last.
|
|
|
|
|
AFAIK A legacy from the presentation manager.
Try this @ home. (B&B)
|
|
|
|
|
A BMP is stored binary that way, the bottom row first, the top row last.
That's not an explanation. That's an excuse!
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
This is a quesion that should be posted in the forums and not as an article. If you provided a resolution for the bug it would have been another story but in the abscense of any workaround or resolution either post it to the forums or report an incident to Microsoft.
"Back in Trivandrum, you'd be dead by now! KEEP OFF!!!"- Nish
|
|
|
|
|
I thought this site was to help each other.
I can imagine that someone detecting the problem will take a look at "Bugs and Workarounds" or search CP for "LoadImage".
If I would be in that case I would be happy to find the info of this small article. That's why I posted it.
By the way:
The workarounds are these:
1) Use an 8bpp bitmap
or if you'd like to stick to your 4bpp one
2) You should be aware that two pixels will be used
(so make sure two pixels have the color you want to be replaced)
|
|
|
|
|
I forgot about Bugs and workarounds section.
It will be good if you can add these workarounds to the article.
"Back in Trivandrum, you'd be dead by now! KEEP OFF!!!"- Nish
|
|
|
|
|