0

I would like to create a dialog box which gives the user the possibility to find a text that has been written in a box. If you look in your notepad.exe on Windows and head to the 'Search'-menu-entry, you will see the box I would like to create. Of course, FINDREPLACE and FindText(...) is able to show such a dialog box but this dialog box has the old windows style of Windows 95 (i guess). Let's check it out, this is the notepad.exe FindText-DialogBox:

enter image description here

and this one has been created with C++ and the FINDREPLACE-stuff:

enter image description here

FINDREPLACE fr;
ZeroMemory(&fr, sizeof(fr));

fr.lStructSize = sizeof(fr);
fr.hwndOwner = hwndOwner;
fr.lpstrFindWhat = szFindWhat;
fr.wFindWhatLen = 80;
fr.Flags = FR_DOWN;

FindTextA(&fr);

Do you know how to create a dialog box which has the modern windows style? I think it has something to do with templates. But I don't know how to create a template and refer with fr.hInstance and fr.lpTemplateName to it.

Strive Sun
  • 5,988
  • 1
  • 9
  • 26
rwCapt
  • 1
  • 1
  • 1
    Another name for dialog template is "Win32 DIALOG resource". You should find many tools if you search for "Win32 DIALOG resource editor". (Pedantically: ok, the template is the content of the DIALOG resource, and it's possible to build one directly in memory instead of loading a resource, but the design is very resource-centric) – Ben Voigt Mar 18 '21 at 16:30
  • 2
    Setting aside your proposed solution of making your own template, most likely all you need to do is "Enable Visual Styles". See https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview and https://stackoverflow.com/a/64038431/103167 – Ben Voigt Mar 18 '21 at 16:34
  • Thank you very much. I had to enable 'Visual Styles'. – rwCapt Mar 18 '21 at 17:41

1 Answers1

0

You need manifest file. The app has to use so-called Common Controls ComCtrl32.dll and call InitCommonControlsEx() API. By this way your app says "I know about new Windows' styles and want to enable them." See this for example: https://www.codeproject.com/Articles/4987/Using-Windows-XP-Styles-in-your-MFC-WIN32-Applicat.

i486
  • 6,491
  • 4
  • 24
  • 41