0

I have an old VC6 application to maintain.

When it starts, it shows the system buttons (minimize, maximize, close) in the usual Windows 7 or Windows 8 style.

As soon as I do an operation that triggers a redraw (SetMenu, move the window…), these buttons change to a Windows 2000 style (just gray boxes with black icons). We have other applications (VC6 as well) that do not have this behaviour.

Any idea where I should start to look ?

Edit: After more investigation, I found that a call to DrawFrameControl is causing all this trouble:

CWindowDC dcWnd(this);

CRect rectWindow, rectClient;
GetWindowRect(&rectWindow);

m_rectDisconnectButton.left = rectWindow.Width() - DISC_BUTTON_WIDTH 6;
m_rectDisconnectButton.top = ::GetSystemMetrics(SM_CYCAPTION) + 4;
m_rectDisconnectButton.right = m_rectDisconnectButton.left + DISC_BUTTON_WIDTH;
m_rectDisconnectButton.bottom = m_rectDisconnectButton.top + BUTTON_HEIGHT;

if ( m_bDisconnectButtonPressed )
    dcWnd.DrawFrameControl(&m_rectDisconnectButton, DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);

If I comment the last call, obviously my button will not be drawn, but I no longer have the issue with the "system buttons".

Philippe Lignon
  • 403
  • 4
  • 10
  • Perhaps there is something like WS_attribute, which can be used to fix the style. As I remember, in C# one could do similar stuff with the "Application.EnableVisualStyles()". First googling returned this approach: http://stackoverflow.com/questions/4308503/how-to-enable-visual-styles-without-a-manifest and additionally this http://www.tutorials.de/threads/xp-style-mit-vc-und-mfc.178395/ – icbytes Jul 11 '14 at 13:50
  • The first approach will not work because VC6 does not recognise this pragma directive. I have found and tested it. The second approach is .NET, not native C++, plus I don't read German. :) – Philippe Lignon Jul 11 '14 at 15:02
  • What is the second approach ? This is mfc. – icbytes Jul 11 '14 at 15:05
  • Anyway, I did find that the problem is that the code is using the API call "DrawFrameControl" to draw a button. Why is it affecting more than just the button drawn with that call? I don't know and this is annoying. I will have to use/implement an alternative way for drawing this button… I have seen a few of these while investigating, I just have to find the best for us. – Philippe Lignon Jul 11 '14 at 15:08
  • Can You post some of the repsonsble code ? – icbytes Jul 11 '14 at 15:09
  • Is the second approach MFC? In spite of what the title says, it looks like accessing the .NET framework, but as I cannot read German, may be I am missing something. Anyway, this is again not supported by VC6. – Philippe Lignon Jul 11 '14 at 15:12
  • He says.that he cannot use the codesnippet ( by the way taken from msdn ) to use it, because he had created his ui with ressource editor and not via code. Anyway, it should also be possible to modify any ressource creator based "ID-recognized" "window-inheriting" elements ( and buttons are such a thing). But I can be wrong, its worth a try. Ah, this looks nice: http://www.codeproject.com/Articles/4987/Using-Windows-XP-Styles-in-your-MFC-WIN-Applicat – icbytes Jul 11 '14 at 15:16
  • I have added the code, but I don't think it will help much in this case, once I know that the culprit is this API call. – Philippe Lignon Jul 11 '14 at 15:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/57165/discussion-between-icbytes-and-philippe-lignon). – icbytes Jul 11 '14 at 15:20

0 Answers0