Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

windows - Win32 custom message box

I want to make a custom message box. What I want to customize is the button's text.

MessageBoxW(
  NULL,
  L"Target folder already exists. Do you want to overwrite the folder?",
  L"No title",
  MB_YESNOCANCEL | MB_ICONQUESTION
  );

I'd like to just change the buttons text to Overwrite, Skip, Cancel.
What's the most simple way?

I have to make this as having same look and feel with Windows default messagebox.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As said by others, a typical way is to create a dialog resource and have a completely independent dialog, which GUI you need to design in the way that it looks like standard dialog (to meet your request for feel and look). If you want to accept text messages, you might probably need to add code which resizes the window appropriately.

Still, there is another option for those who feel like diving into advanced things. While MessageBox API does not offer much for fint tuning, you still have SetWindowsHookEx in your hands. Having registgered the hook, you can intercept standard MessageBox window procedure and subclass it in the way you like.

Typical things include:

  • changing button text
  • adding more controls
  • adding timed automatic close

Hooking standard window can do all of those.

UPD. Hey, I realized I have some code with SetWindowsHookEx to share: http://alax.info/blog/127


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...