|
Check out this[^] article, maybe it can give you hints. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks for your answer.
I cannot argue that I can't use anything from it. But it still doesn't answer the main part of my question: how do I prevent Windows from painting the tab control background. I cannot use the sample directly because I don't have MFC (that's why I'm using Win32).
Thanks.
Anton112
|
|
|
|
|
Did you try handling WM_ERASEBKGND[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yes, I have tried. It makes no difference.
Anton112
|
|
|
|
|
I'm out of ideas right now, sadly afaik in many controls the WM_PAINT message and such sort does not get always invoked when drawing occurs, instead probably the drawing code gets called directly by who knows what event handlers. I have seen this happening a few times. Of course i could be wrong...
Anyways, try adding the WS_EX_TRANSPARENT style, no idea if it changes anything or even if it does not make things worse, it's just a hinch.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Apperently, WS_EX_TRANSPARENT makes no difference.
Anton112
|
|
|
|
|
Are you handling WM_DRAWITEM[^]?
Best Wishes,
-David Delaune
|
|
|
|
|
|
Sorry, what is AIM?
Anton112
|
|
|
|
|
Hi David, and thanks for your interest.
I have analysed my problem a bit more. WM_DRAWITEM is not sent at all. WM_ERASEBKGND is sent only upon repaint of the application (focus changed, window rezise etc.). If I add return 0; to WM_PAINT, Windows stops updating the tabs, but the application is not updated either. By adding a flag to control WM_PAINT when the mouse is within the tab area (WM_MOUSEMOVE and WM_MOUSELEAVE) I can override Windows update, but only as long as the mouse is within the tab area.
Do you have other ideas to which events I could respond?
Kind regards
Anton112
|
|
|
|
|
Hi Anton,
There may be some useful information on the link provided below. Looks like the Tab control will require some ugly hacks to be fully customized.
Hacking the Overall Background Color of a Windows Tab Control[^]
I looked at a customized tab control I wrote a few years back and it looks like I was doing something similar. I was essentially drawing on top of what was already drawn!
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
I have to realize that it is too long time ago I wrote code for Windows last.
First, I used GetDC/ReleaseDC to get the DC for WM_PAINT where (I suppose) it should have been BeginPaint/EndPaint .
Second, I used the hWnd entered through the WndProc call for one of the functions and the locally stored m_hWnd for the other. I.e. GetDC(hWnd) ReleaseDC(m_hWnd) . I don't hnow if it causes any trouble, but it is not very nice.
Anyway, now I can prevent Windows from drawing the tabs, and the spin control is controlled by Windows (except in the vertical alignment: they are painted but not handled ). The remaining problem is that I have to draw the whole tab background by myself. But I expect it to be a relatively small problem.
Best regards
Anton
Anton112
|
|
|
|
|
Hello.
I have the hwnd of another window and I am trying to get the text. I know how to get text from another window (WM_GETTEXT) but I don't know hot to get the text from the currently focused control in that window.
Unfortunately GetFocus() won't work so I am out of ideas.. I would even try using EnumChildWindows, but I don't know how to find out if a particular control is focused.
Can anybody help? Thank you in advance.
|
|
|
|
|
nc3b wrote: Unfortunately GetFocus() won't work...
Is it because the window (containing the control) is in another thread?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes, it's in a different program.
|
|
|
|
|
Then you may need to use GetGUIThreadInfo() first.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Can you please give an example?
Suppose I have a HWND of a window (GetForegroundWindow()) and wnat to get it's focused child. How would I do that? Thank you.
|
|
|
|
|
First you need to get the list of processes that are running to find the one you are interested in. This can be done by calling CreateToolhelpSnapshot() , and then looping through each one with the ProcessFirst() /ProcessNext() pair. Once found, use the PID as the first argument to GetGUIThreadInfo() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
And then "hwndFocus" will contain the hwnd of the curently focused control? Thanks!
|
|
|
|
|
consider [GetWindowThreadProcessId^] also for getting the processid of the foreground window and thread id needed for GetGUIThreadInfo
|
|
|
|
|
|
I am assuming you mean getting who has the focus in a different process, so try this[^] for size.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I have a template function to check the type passed to it. I am templatizing it on a derived type but when I break in the function, the template parameter is the base class. A sample app is below. Can someone please explain where I am going wrong?
Thanks
class Base
{
public:
virtual ~Base() {}
};
class Derived1 : public Base {};
class Derived2 : public Base {};
template<class T> bool CheckType(boost::shared_ptr<Base> pBase)
{
T* pTemplate = NULL;
Base* pBaseRaw = pBase.get();
if(typeid(pBaseRaw) == typeid(pTemplate))
{
return true;
}
return false;
}
int _tmain(int argc, _TCHAR* argv[])
{
boost::shared_ptr<Base> pBase1(new Derived1);
boost::shared_ptr<Base> pBase2(new Derived2);
bool bIsDerived = CheckType<Derived1>(pBase1);
bIsDerived = CheckType<Derived2>(pBase2);
return 0;
}
|
|
|
|
|
A few questions:
- If I understand you correctly, CheckType is returning true, but you expected false?
- What compiler (& version) are you using?
I've just tried your code with g++ 4.0.1 and it gives the results I'd expect. I added some code to print out type names:
template<class T> bool CheckType(boost::shared_ptr<Base> pBase)
{
std::cout << typeid(T).name() << std::endl;
T* pTemplate = NULL;
Base* pBaseRaw = pBase.get();
std::cout << typeid(pBaseRaw).name() << std::endl;
if(typeid(pBaseRaw) == typeid(pTemplate))
{
return true;
}
return false;
} . I also printed out the result of CheckType and got these results:
8Derived1
P4Base
0
8Derived2
P4Base
0
So - the template parameter is Derived, the parameter is a pointer to Base, CheckType is returning false. I'm suspecting that the compiler you're using isn't fully standard compliant if it does something different?
|
|
|
|
|
Thanks for the response. Your output is what I expected. I was looking at the pointer types in the debugger, not printing out the type info to the console. The print statements give me what you got. I am using VS2008 v9 SP1. I was performing the wrong check to get a type match. I changed the function to the following:
template<class T> bool CheckType(boost::shared_ptr<Base> pBase)
{
Base* pBaseRaw = pBase.get();
if(pBaseRaw == null)
{
return false;
}
if(typeid(*pBaseRaw) == typeid(T))
{
return true;
}
return false;
}
I am now dereferencing the base class pointer returned from shared_ptr which casts it to the right type. I believe this is a sketchy implicit cast to the derived type. Should I just dynamic_cast or does the typeid comparison take care of type issues?
Thanks
|
|
|
|