Currently viewing: GipsySoft » Front Page» Articles

GSMessageBox - Center to parent

The code

GSMSGBOX msg = { 0 };
msg.cbSize = sizeof( msg );
msg.uFlags = GS_MSGBOX_CENTER | GS_MSGBOX_CENTER_TEXT;
(void)GSMessageBox( NULL
		, _T("Centered Test.\nNew line\nAnd another!")
		, _T("Caption")
		, MB_OKCANCEL
		, &msg );

Notes

All we do is declare an appropriate structure, set some values and then call the API.

  • GS_MSGBOX_CENTER centers the MessageBox to it's parent.
  • GS_MSGBOX_CENTER_TEXT centers the text within the MessageBox.