|
My program has a view inherit from CView,when it receive WM_SETFOCUS I want do something,but the view receive WM_SETFOCUS message only once when program starting.why?
linjie
|
|
|
|
|
linjie wrote:
the view receive WM_SETFOCUS message only once when program starting.
What are you using to verify this? I tried this and used Spy++ to see the messages. The application received multiple WM_SETFOCUS messages.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Because CView has the focus of the OS.
From MSDN Library
-----------------
The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus.
The SetFocus function sends a WM_KILLFOCUS message to the window that loses the keyboard focus and a WM_SETFOCUS message to the window that receives the keyboard focus. It also activates either the window that receives the focus or the parent of the window that receives the focus.
If a window is active but does not have the focus, any key pressed will produce the WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP message. If the VK_MENU key is also pressed, the lParam parameter of the message will have bit 30 set. Otherwise, the messages produced do not have this bit set.
By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window associated with another thread's message queue.
|
|
|
|
|
I need to implement ICopyHook interface inorder to intercept copy,rename and delete commands. I have basic knowledge of COM, Can anybody give me some guide lines as in how to begin implementing this ??
Please note I am looking for very basic tips, starting from how to create my own interface? is it like adding class ?? if yes whats the procedure ??
any and every help would be much appreaciated.
Thanks
Abhishek Narula
|
|
|
|
|
|
Thanks Mike, just downloaded your articles appears to be exactly what I was looking for .. Thanks the help.
Regards,
Abhishek Narula
|
|
|
|
|
We are using the 'Crystal Report Control 4.6' as an OLE component in VC++. While using the SetAction() function provided by the OLE component, we are getting an error "Unable to load Report".
If some one has worked on the same or has any idea how to rectify the error please respond. Thanks
ThomasKennedyBose
|
|
|
|
|
Hello,
i have problems creating a larger projects.
i want my project to have a directory structure like this
main
+ bin
-+ debug
-+ release
+ source
-+ project1
-+ project2
-+ project3
what is the best way to start this?
how can i reuse these settings for new projects?
all ideas are welcome.
|
|
|
|
|
I am developinng a MDI application.
Wanna know if there are ways to record how many windows
were open last time when you close an application.
Just like photoshop.
Shin
|
|
|
|
|
I am not sure your question.
Do you wanna restore all windows opened last time when you run your application again, or just record the number of windows.
For the latter one, you can write this as a key into your ini file or registry before you destory all your windows.
Nice to learn
yfmain
|
|
|
|
|
Hi,
Can we use the BOOL and bool interchangebly in a VC++ code.
That means can true and TRUE be used interchangebly?
I have a piece of code, working fine but using false for a BOOL variable.
Regards,
Saurabh
|
|
|
|
|
|
I think the Frankie goes to hollywood song "Relax, don't do it" comes to mind.
|
|
|
|
|
BOOL is a Windows typedef, 4 bytes long. Its values are TRUE and FALSE .
bool is a built-in C++ type, 1 byte long. Its values are true and false .
That's all you need to know. Don't mix them. Sure, if you write:
BOOL b = false;
it will work, but it also looks like you don't know the difference between BOOL and bool . If you write this during an interview, it will reflect unfavorably on you.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
BOOL
====
typedef int BOOL;
bool From MSDN Library
=======================
In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1. This can cause memory corruption problems if you have defined structure members of type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or DLLs built with the 4.2 and 5.0 or later compilers.
|
|
|
|
|
hi
can anybody send me a fingerprints recognition code. in vc++ or any other language. or even tell me where to get tht code.
i'll b very thankful to u ppl
|
|
|
|
|
Right now, I'm doing this:
CPaintDC dc(this);<br />
CBrush brush(RGB(255,0,0));<br />
HBRUSH oldbrush=(HBRUSH)dc.SelectObject(&brush);<br />
...<br />
dc.SelectObject(oldbrush);
It works, but there's a HUGH memory leak. If I remove the SelectObject() lines, there's no leak anymore, so I assume that it's the SelectObject() , or the Brush maybe. But objects are destroyed at the end of the scope, no?
Is there another solution that guarantees complete release of resources?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Changed to this:
dc.SelectObject(brush);
and the leak is gone.
So, you should pass a copy of the object instead of the pointer to the object. Strange, cause I've seen this code hundreds of times on this site...
I was stuck with this for a couple of days, and you'll always see that the moment you post a question about this, you'll find the solution yourself. Sorry about that.
|
|
|
|
|
You could try
dc.SaveDC();
and
dc.RestoreDC(-1);
to save and restore the DC state. That should work.
The brush and any other objects can only be destroyed if they are not being referred to by the DC, so your stuff should work anyway...
Steve S
|
|
|
|
|
It works, that's true ... but after 5 seconds you've wasted 512 meg of ram.
Adding dc.SaveDc() and dc.RestoreDC(-1) doesn't make a difference, still leaking.
Passing the brush object instead of the pointer is the only thing that works. But then we are using deep copies (I assume that) and that doesn't speed things up.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Your mix of things might be why.
Does
CBrush* pOld = dc.SelectObject(&brush);
...
dc.SelectObject(pOld);
still leak?
Steve S
|
|
|
|
|
That results in a crash when selecting a pen instead of a brush (selecting a brush is doing allright).
Strange...
Is it the stockobject?
CPen* oldpen=(CPen*)pDC->SelectObject(GetStockObject(NULL_PEN));
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Wouldn't it be easier to use pDC->SelectStockObject(NULL_PEN) ?
There are caveats to do with the fact that the pointer may well, in this case be to a temporary CGdiObject, so shouldn't be used in different messages.
I normally use SelectStockObject, or failing that,
CPen* oldpen = (CPen*)pDC->SelectObject(CPen::FromHandle(::GetStockObject(NULL_PEN)));
I prefer use of an explicit FromHandle() call rather than relying on a cast operator.
Steve S
|
|
|
|
|
SelectStockObject instead of SelectObject(GetStockObject) does the trick.
tnx.
|
|
|
|
|
This eats ram like hell too:
CPen pen(PS_SOLID,1,m_clrForeground);<br />
CPen* oldpen=(CPen*)pDC->SelectObject(&pen);<br />
...<br />
pDC->SelectObject(oldpen);
I don't understand this, it's code I see a lot. I feel kinda stupid...
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|