|
Oh MAN! NEVER draw controls off the left side of the visible area of the window!!
Then they go into that great mysterious void and re-emerge in other people's windows....not good.
On a more serious note:
Negative coordinates are valid. It's just by design that the origin point (0,0) of the client
area of a window is at the upper-left of the window.
Anything outside the visible area of the window will be clipped.
No problem.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
Thanks for the quick response. I know, I take it you're joking on your first comment, but in all my times of programming in MFC/VC++ I am always, always, always very careful to use functions only how they were designed because I have found that when I don't strange things can in fact happen - even the ones you mention. My favorite is when something works on 9 out of 10 machines (and you don't find it until post-implementation). That's what I was worried about here.
Do you know if any MS documentation exists stating that areas outside the window are clipped? I would not find to too far-fetched if MoveWindow() is poorly implemented and passing in negative x,y values resulted in some memory somewhere being overwritten...
Zeke
|
|
|
|
|
I can't find a specific documented sentence that states this.
This has been the behavior of windows since the start of Windows.
Windows has always kept mis-behaving apps from drawing outside their windows.
You can move all your controls yourself for scrolling if you want to. You're also free to hide
child windows that are outside the visible client area of the window if you feel better about it.
Of course, for child windows partially outside the client area of the parent, you'd need to handle
all clipping. It could be a lot of work for something Windows will do with one function call...
The ScrollWindowEx() API will move the child windows for you if you use the
SW_SCROLLCHILDREN flag. If you try this, you'll see that Windows happily moves the
child windows to negative coordinates.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Cool, much appreciated feedback Mark. Originally my plan was to just hide the controls where any part of them were outside the client area but I think it looks cooler if the controls only disappear beyond the viewable area.
Also, I wasn't aware of ScrollWindEx(). Looks like it will be useful for what I'm doing.
Thanks again, you the man!
Zeke
|
|
|
|
|
Dear Zeke,
your pose was very interesting and the solution given by MARK is highly appreciable.
even i had this doubt long ago,
but some body misleaded that, it is not possible,
so i took it easy.
i request you to prefix your subject name with [SOLVED] such that, it will be very good to see it on the forums.
i request all the other members to follow this idea.
|
|
|
|
|
Hello,
I'm working on an application that uses the Scheduled Task APIs... I am unable to get the "detailed status" that appears in the GUI from anything in the API.
For example, let's say I've got a scheduled task that has a bad user/password.... in the Win2003 GUI, the "Status" column has the following:
"The scheduled task did not run because an incorrect password or user name was entered"
However, nothing in the API can get me this error code (0x8007052E)... I've tried:
ITask.GetStatus = returns 0x41300 (Which is "Task is scheduled")
ITask.GetWorkItemData = return a 0 for the length of the data (so there is no application specific data)
ITask.GetExitCode = return 0 because the last time it did run, it ran fine
What am I missing?
Visuall C++ 6.0 using Microsoft Platform SDK for Windows Server 2003 R2
on Windows XP Prof SP2
|
|
|
|
|
|
I used Win32 and MFC.
I try launch exe file with commands line. How to this?
example: "c:\dir1\form.exe cmd1"
thanks
|
|
|
|
|
Assuming you want to do this programmatically, you could use the
CreateProcess() API - check out the first two parameters.
There's more useful info at Michael Dunn's MFC FAQs[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Does ShellExecute helpful?
|
|
|
|
|
Take a look at ShellExecuteEx() in MSDN.
(Hint: you need the _T("open") verb.)
|
|
|
|
|
hi
do u know how can i disable expansion of what i've collapsed to definition which automatically occurs when i wait remaining on the line? i need not it to expand and want it to remain in the definition and collapsed until i manually toggle outlining.
thx
|
|
|
|
|
When determining if the value stored in an object is less than that stored in another object we define the operator ‘<’; how it is defined is very important. But how do you define the operator for a class with multiple data items, so that you get the correct results?
For reasons that I am not going to go into, we do not care what data is stored or what its actual value is. We simply need to be able to determine whether one object is less than another for the purpose of adding it to an STL container that requires the information.
One solution is to just do a simple ‘memcmp()’ , which does work under normal usage of this particular class. The reason it works is because the ‘data_type’ is normally an integral type.
The problem is that the data type is unknown, as the class is a template and the type is supplied by the user. If the data type is a class that contains no memory pointers, the above solution will still work. But if the data type is a class that contains a memory pointer, such as a ‘std::string’, then the above solution is invalid because comparing data pointers is not the same as comparing the data pointed to.
For the purposes of comparison, every piece of data (data_, f1_,…, and id_) must be used. The ‘memcmp()’ method produces the correct results for integral types, but every other method I have tried fails. The results of the comparison must be the same as that produced by the ‘memcmp()’ method.
Note that “(data_ < rhs.data_ || f1_ < rhs.f1_ || f2_ < rhs.f2_ || f3_ < rhs.f3_ || id _ < rhs.id _) ” does not work, nor other variations on that theme.
Example class:
class this_class
{
data_type data_;
bool f1_, f2_, f3_;
int id_;
public:
…
bool operator<(const this_class& rhs) const
{ return( memcmp(this,&rhs,sizeof(class)) < 0 ); }
};
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
try also sizof .
But, of course, you can't know the size of objects related to the class through pointers.
There isn't a solution, ... or, if you want, the solution is do not implement this operator, because it can't work correcty (as you tell) everytime.
Russell
|
|
|
|
|
Try the following:
data_<rhs.data_ ||<br>
(data_==rhs.data_ && f1_<rhs.f1_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_<rhs.f2_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_==rhs.f2_ && f3_<rhs.f3_) ||<br>
(data_==rhs.data_ && f1_==rhs.f1 && f2_==rhs.f2_ && f3_==rhs.f3_ && id_<rhs.id_)
Steve
|
|
|
|
|
Thanks, I was afraid something like that would be required. It works in debug mode, as it should, but fails in some cases in the release version; I need to look into why that is. Since the “operator<” may get called thousands of times in some cases I may make it a compile time option and stick to the “memcmp()” solution, as I suspect the call is cheaper than all those tests. I’ll need to run some tests to be sure.
I see no reason why anyone would use anything but built in data types in this class, but I would still like to leave the option open.
Thanks again.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
You could get the best of both worlds using something like Boost[^]'s TypeTraits[^] library. See this[^] example for an example of something similar (although not exactly what you want).
Steve
|
|
|
|
|
Thanks, I decided to go with the current solution (memcmp) and restrict the usage to integral types as per my original specifications. I tend to let my imagination run wild at times and was trying to add flexibility that even I would never use.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I've been known to fall into that trap myself.
Steve
|
|
|
|
|
i've looked thru the official guid, very brief though...
|
|
|
|
|
Does this a c++ question ?
|
|
|
|
|
Hi every1, I need help related to image recognition using Genetic Algorithm.(GA)
Would greatly appreciate if anyone can send me any related information eg source code or notes that I can read or used as I am quite confused by the GA implementation in C++.
How an image is recognize/identified using GA?
Simple comparison like character recogntion, Neural network can performed task by training to identified the character, do GA able to perform similar task?
Can email to ray_luee@yahoo.com
Thanks
RayLuee
|
|
|
|
|
I have decided to bite the bullet and find out how to convince MFC that passing parameters to implement IMPLEMENT_DYNCREATE is feasible.
In a nutshell - IMPLEMENT_DYNCREATE access only the default constructor which has no parameters. Tiring to hack the RUNTIME_CLASS and the whole chain down to creation of the object is a nightmare.
The basic for this is that I have a need / want to use same view class with different "parameter". I am basically tired of building a copy of the view class and modifying its methods as required.
There are few articles in here which accomplish this using various approaches - RTTI, "Generic Class Factory" (no longer supported by the author) etc.
I am asking the forum to share experiences with these approaches.
Recommendations, comments etc.
Thanks for your help.
Vaclav
|
|
|
|
|
Hello all. So I have these three combo boxes. According to certain validations, I have to select one of them. I thought that simply calling CComboBox::SetFocus would be enough, yet it is not working. I also tried sending a WM_ACTIVATE messages to the combos, with the same results.
Any thoughts would be really appreciated. Thanks in advance.
FG.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
From where you call this?
- NS -
|
|
|
|