|
Geez, man - do you know how XOR works?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
|
> 1 xor 1 makes 0
And what about 1 xor 0, 0 xor 1 and 0 xor 0? If you draw rectangle *twice* in XOR mode, it will disappear and your original picture will remain intact. XOR 'toggles' bits - zeros become ones and vice versa. Two XORs give you original bits. Of course, you have to ensure that rectangle coordinates do not change. Is that clear enough?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Ok, I tried DrawFocusRect which is XOR function.
CRect rc (0, 200, 200, 0);
pDC -> DrawFocusRect (&rc);
in my OnPaint (). I see no rectangle on the screen.
I doubt now. I believe DrawFocusRect draws in logical coord. space.
Mapping mode, window origin and extent are set accordingly. Everything seems to be all right. Did I something wrong?
|
|
|
|
|
From the DrawFocusRect documentation:
"DrawFocusRect works only in MM_TEXT mode."
If you need some other mapping mode, the only way is to call SetROP2 and draw rectangle manually. You can use MoveTo/LineTo or set a brush to GetStockObject(NULL_BRUSH) and call Rectangle. I'm assuming you need only outline of the rectangle - as specified in original post.
You can check KB article Q135865 to get sample on "How to use Win32 API to Draw a Dragging Rectangle on Screen DC". Your task is probably easier - you'll be drawing inside your own window only. You can also search for "sample setrop2" in your VC++ help - this search gives more than 20 hits on my workstation.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
You are right, I'm using MM_ANISOTROPIC mapping mode.
Now I'm trying:
CRect rc (10, 200, 200, 40);
pDC -> SetROP2 (R2_NOTXORPEN);
pDC -> Rectangle (&rc);
It looks fine. This is what I wanted. THANKS!
|
|
|
|
|
I'd code it differently. Assuming that you want to decrease dialog height to hide the button, it would look like this:
CRect rcDialogClient, rcDialogWindow;
GetWindowRect(rcDialogWindow);
GetClientRect(rcDialogClient);
CRect rcBtnWindow;
m_btn.GetWindowRect(rcBtnWindow);
ScreenToClient(rcBtnWindow);
int cyDelta = rcDialogClient.Height() - rcBtnWindow.top;
SetWindowPos(NULL, 0, 0,
rcDialogWindow.Width(),
rcDialogWindow.Height() - cyDelta,
SWP_NOMOVE | SWP_NOZORDER);
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks for the reply Tomasz, but I actuall thought of something similar after I had just posted it... and deleted the post, thought no one would have seen it yet.
cheers,
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Hi there ,
I GOT A SIMPLE PROBLEM.I AM COMPILING A VC++ ( 5.0 ) PROGRAM WHERE I AM HAVING A DIALOG BOX APPLICATION.IN THE DIALOG BOX I AM HAVING A EDIT BOX WHER5E I WISH TO DISPLAY THE VALUE OF THE ITERATION COUNT IN THIS EDIT BOX . SIMPLE !!!
THE CODE I HAVE WRITTEN ON MOUSE CLICK OF A PUSH BUTTON IS AS FOLLOWS.
:: OnPress()
{
for ( int i=0;i<10;i++)
{
m_number=i;
UpdateData (FALSE );
Sleep( 1000 );
}
}
m_number is variable associated with the edit box and is integer type.When i run the program only last count i.e 9 is displayed in the edit box.why not all count is displayed in the edit box?
Can somebody please guide me?Why this is happening.
Thanks in advance.
Lets share our knowledge and make this world even more beautiful.
|
|
|
|
|
I believe it has to do with your calls to the Sleep() function. The sleep function was not realy meant to be used in this maner. What the sleep function does is suspend the execution of your current thread. So your edit box wont even have time to update itself before the sleep starts... or even after. I imagine the only thing displayed in you edit box, after 9 seconds, is 9.
I'd recomend looking at using a timer, and update the edit box with that.
-Ben
"Its funny when you stop doing things not because they’re wrong, but because you might get caught." - Unknown
|
|
|
|
|
Think : "Message pump". I do not believe that UpdateData forces messages to be processed for the windows in question, thus your edit window is not refreshed until you fall out what ever message handler you are in. In other words, the message pump is suspended while your loop is processing thus the window you wish to display the result in never recieves the message to update itself with the value. You will need to force the message pump to run from within your loop.
Try adding a method like this to your dialog, and call it from within your for loop:
BOOL
CFWThumbsDlg::ProcessMessageQue()
{
MSG msg;
while( ::PeekMessage((LPMSG) &msg, (HWND) NULL, 0, 0, PM_REMOVE ))
{
TranslateMessage((LPMSG) &msg);
DispatchMessage((LPMSG) &msg);
}
return( TRUE );
}
|
|
|
|
|
Hi.
Your code would be right for a console (or DOS) app, which is run as a sequence.
As mentioned above, you block the message pump, because you do your work in thread which runs the GUI of your app. So you block the whole app!
There are some ways to avoid this problem:
1. Use threads
Count in a thread and send the changes as a (User-)message to the main window.
2. Use a timer
Create a timer when clicked on "Start" and kill it when clicked on "Stop"
In the timer routine you can do your UpdateData().
A propos: Never forget to call UpdateData(TRUE) before UpdateData(FALSE) !!
Learning to make a good desing will save you a lot of trouble!
Bye, Karl
|
|
|
|
|
I'm using VC6 SP5. Sometimes whilst coding I right click on the source code window, to bring up the context menu, and then click the ClassWizard item. Sometimes for seemingly no reason at all, the ClassWizard item is disabled, and will stay displayed until I close down, and restart VC6.
Anyone know why?
|
|
|
|
|
Hi,
I get an Stack Overflow in my project.
( Had problems with w98 and so start work under NT4, after some time my w98 was reinstalled, so I want to run the app under w98 ...)
Does anyone know where I can enlarge the Stacksize.
Thanks
RW
|
|
|
|
|
use (/STACK:reserve[,commit]) linker option.
Normally 1MB of stack is more than enough
|
|
|
|
|
It looks like infinite recursion problem. Increasing the stack size won't help you in this case.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Are there any more relevant websites?
|
|
|
|
|
You can use Vision SDK from Microsoft.
http://www.research.microsoft.com/projects/VisSDK/
|
|
|
|
|
Hi there,
In our aboutbox we want to write the version informationa about the .exe were developing.
I was wondering if anyone know of any mfc way to retrieve the information ?
K
|
|
|
|
|
AFAIK, MFC doesn't help there. You need to code using the following API functions:
GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue
First, you call GetFileVersionInfoSize to get the size of the version block. Next, allocate the memory and call GetFileVersionInfo. Finally, retrieve version # using VerQueryValue.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
OK, I know this sounds crazy (or at least it does to me), but I apparently when using the ListView control with multi selection turned on, you do not get WM_LBUTTONUP messages. (Q149275 and Q149326 in MSDN). Does anyone know of a better workaround than hassling with setting a window Hook to try and trap the message ? It definitely is there in - you can see it using Spy++.
What a stupid damn thing to have to track down ! Oh well -
Any help will be much appreciated
|
|
|
|
|
Does WM_LBUTTONUP show up in PreTranslateMessage? Just an idea
|
|
|
|
|
These KB articles describe problems with Visual Basic control, not the listview in general. And you see these messages in Spy++ - so what's the problem - your handler is not called?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Well first off I'm not using MFC though I did a test and the same thign happens.
I have sub classed the listview control, and in my WndProc the WM_LBUTTONUP does not get called except under odd circumstances as described in the KB articles. For example - I can click on another window, drag the mouse ovwer the list view, and then release, and then I get a WM_LBUTTONUP, but just a press and release of the mouse on the listview control does not send a WM_LBUTTONUP.
If I set the LVS_SINGLESEL style bit then I do get WM_LBUTTONUP as long as I dont click on any item. This is very weird ? This also happens in MFC. I don't know if this matters but I am using VC++ 6.0 professional with no service packs - maybe this is the problem
|
|
|
|
|
I'm afraid service packs are not a issue here. The problem exists deep inside comctl32.dll, where list control wndproc lives.
From the "Default List View Message Processing" in MSDN:
"WM_LBUTTONDOWN: Processed in different ways depending on whether a click or drag operation is being initiated. To determine which operation is involved, the list view control enters a modal message loop until either the button is released or the mouse is moved. [...] If dragging begins over the window background, the list view control enters another modal message loop, enabling the user to form a rectangle by dragging the mouse. Items within the rectangle are selected."
The keywords are "modal message loop" - listctrl wndproc uses its own GetMessage/TranslateMessage/DispatchMessage loop, which you can't override - seems that you'll need a hook.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|