|
I have already tried to use the WS_EX_LAYERED style and the UpdateLayeredWindow function to get the image displayed and it works fine. But the problem is I want to add child controls to my window and with this approach they are not rendered.
|
|
|
|
|
Well, if you use layered windows you have to draw (and possible also handle) controls yourself. As far as i know there's no safe, reliable way to do what you want to do (i mean the way you are trying to do it). An alternative can be using Window regions[^], you can use these with windows displaying normal controls BUT this does not give you a nice look, it just lets you clip the window to some shape, but you can't nicely antialias the window for example. Another way would be combining a layered window and a non-layered window. The layered part would contain the transparent parts and the non-layered part would contain the controls, you would need to keep the Z-Order and visibility state synchrnoized between the two types of windows. It is probably a pain in the ass to implement correctly but it can be done.
> 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. <
|
|
|
|
|
Just to clarify things up, here is what the window looks like: http://img52.imageshack.us/img52/3956/81503777.jpg
And here is what happens when I move the window over the desktop: http://img186.imageshack.us/img186/7079/96798366.jpg
What do you think would be the best way to display this kind of window (transparent background image + controls)?
Thanks!
|
|
|
|
|
Have you tried calling OnNcPaint() while/after moving the window?
L u n a t i c F r i n g e
|
|
|
|
|
Not yet, I will give it a try.
I solved the problem by using two windows, one for the background (WS_EX_LAYERED) and one for the controls
|
|
|
|
|
It was just a thought I had after looking at the images. It looked as if it was the non-client area that wasn't getting updated properly. I've no idea if it'll work or not.
L u n a t i c F r i n g e
|
|
|
|
|
I guess it is too late now since your other post(s) tell me you did with the "1 layerer + 1 normal window" solution but yepp, i would have recommended that also. Your app looks nice, btw...
> 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. <
|
|
|
|
|
C is a terrible language, it has no class, it has no object in life, and it can't inherit anything. But it got nothing to hide.
|
|
|
|
|
Nah, C is good. Is the only language enforcing free dom.
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,
I want to write a small mfc dialog based program to test the functionality which the third-party library provides.
The flow of test program is simple. I made some buttons on the program.
When I pressed button A, then execute the action A. Pressed button B, then execute the action B...etc.
According to the library document, each action usually contains 3~5 steps.
Each step must call some functions which are provided by the library.
The document said some functions will use PostThreadMessage() to send some specific library-defined message within a specific time.
If the program doesn't receive library-defined message within a specific time, regard it as timeout.
And the frequency of this type function is often, not a little.
But now I don't know how to do this timeout functionality properly.
For now, I used a for loop and difftime() to check the time period repeatedly and didn't create any new thread in my program.
In the for loop, I use GetMessage(&MSG, 0, 0, 0) to receive the message which library function sent.
Although the library function can't work (because the library relies on a specific machine, and the machine doesn't connect to my pc),
I think that it's enough to test the timeout functionality.
But the test result seemed that it didn't work correctly. I use a MessageBox() which is outside the for loop.
And the message box always was showed later than the time I set.
Another problem is if I pressed the button to start the timeout functionality then press the OK or CANCEL button earlier than the timeout
message box, the program will disappear but still resides in the task manager...
(Even if I add OnDestroy() to call DestroyWindow(), the result is same)
So I thought the method which I use now is correct or not. But even it is the incorrect method, I don't know what the proper method is...
So does anyone can give me some suggestions, helpful references, related samples or why my program failed ?
Thank you very much.
|
|
|
|
|
oppstp wrote: The document said some functions will use PostThreadMessage() to send some specific library-defined message within a specific time.
If the program doesn't receive library-defined message within a specific time, regard it as timeout.
And the frequency of this type function is often, not a little.
But now I don't know how to do this timeout functionality properly.
What's to do other than respond to the messages that the library is sending? If the messages are being posted (rather than sent), you do not even have to respond to them in a timely manner.
"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
|
|
|
|
|
DavidCrow wrote: What's to do other than respond to the messages that the library is sending? If the messages are being posted (rather than sent), you do not even have to respond to them in a timely manner.
Thanks for the reply.
I think that the library is used for customers.
So it has the timeout functionality to prevent from the wait of customers.
If I don't receive the the library-defined message(might be network error or other reasons).
I will show the related message to the customers, not waiting for the response infinitely.
That's why I think the docoument asked the developers to do timeout functionality.
|
|
|
|
|
Hi All,
I want to display a large bitmap inside a picture control.I want the picture control to display the vertical and horizontal scroll bars automatically when the image size is larger than the picture control.How do i achieve this.Please help.
Thanking all in advance,
Ashwath.
|
|
|
|
|
I have just begun using C++ and cannot seem to figure out an effective way to accept thousand separators (Only commas) in a simple program.
Basically, I need to be able to validate whether a number (given by the string argv[1]) is correctly formatted or not, before I remove all commas and convert it to double/float.
Valid Input: +1,234.5E-1,234.5 (even +a,bcd.eE-a,bcd.e for now) >> Output: +1234.5E-12345.5 (+abcd.eE-abcd.e)
Invalid Input: 1,0 >> Output: X
Any help regarding this issue would be greatly appreciated.
|
|
|
|
|
why dont you look at regular expressions ? - they allow you to 'describe' what input should look like and then perform match tests for example
The other issue you might have, is, if you are writing for an international audience, the thousands separator is different depending on there you are :-
Aus : 1,234.00
France : 1.234,00
just two examples ...
ps .. as a start for your regular expression, consider
([0-9\-\+\.].)
the [] denote the start of a 'character 'set' - there some predefined ones like :digit:, :alpha: , in this case Im saying match any character from 0 to 9, ie 0 1 2 3 4 5 6 7 8 9 .. -, +, . usually have a meaning in a regular expression (regex) to that need to be 'escaped' to say treat them as is.. the last '.', ie right before the right bracket ')' , is not escaped, which means '1 or more repetitions (iirc) else what that would match would be a single digit number .. the () denote a 'match sub/group' - so if I had an array of matches returned by a regex, match[0] would be the entire matched expression, match[1] would be the first bracketed set etc
anyway, Im waffling - do a google on regular expressions, play with them in the language of your choice - they are well worthwhile spending time on
'g'
|
|
|
|
|
Are you taking internationalization into consideration? I mean, ten thousand is still ten thousand whether you write it as 10000 or 10,000 or 10 000.
Can you not just remove the commas and then convert using something like _gcvt() ?
"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
|
|
|
|
|
me again - see this for a starter
http://onlamp.com/onlamp/2006/04/06/boostregex.html[^]
unfortunately a smaller regex library John Maddock had on is home pages seems to have gone (it was an ourworld.compuserve account, so you'll have to download and build boost, which is where the library has gone anyway - well worth it even if you just build the regex library)
'g'
|
|
|
|
|
Just parse it; the code isn't at all difficult.
One of the lessons of programming is that simple brute force code is quite common and very effective. Don't think fancy, just think simple.
|
|
|
|
|
Thank you for all of your help. But I need to be able to perform the code without any additional downloads (such as the <regex boost.htp=""> library). Parsing it sounds like a good option at the moment. Also, I only have to deal with comma thousand separators, but I need to be able to tell whether they are valid or not (1,000,000 = Valid, 1000,000 = Invalid)
|
|
|
|
|
awesometrickycool wrote: ...I need to be able to tell whether they are valid or not (1,000,000 = Valid, 1000,000 = Invalid)
Why is that invalid? It's still one million.
"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
|
|
|
|
|
Yes, but if i were to remove all commas, then ,,,1,0,,000,00 would also be valid. So I just want to remove the valid commas (Eg. 1,000,000 = 1000000 (valid). 1,000,00,0 = 100000,0 (invalid). Sorry if this is a bit confusing.
|
|
|
|
|
awesometrickycool wrote: Sorry if this is a bit confusing.
Not confusing, but trying to account for every possible combination of digit separator (not all countries use a comma) is not a trivial task. A regular expression could be used after the fact to verify what was entered. A masked edit control could be used during the time of input.
"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
|
|
|
|
|
Parse the string, counting digits. If you get to more than three before the first comma (or period), error. If you don't get exactly three before the next comma or period, error. And so forth.
|
|
|
|
|
But how would this work for a complex variable such as +1,234.5E-1,234.5? And what is the command for parse (How do I begin to write such a code)?
|
|
|
|
|
You'd have to pull out the two numbers from both sides of the E to see if they are valid.
"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
|
|
|
|