Page 1 of 1

MessageRequester #MB_ICON

Posted: Mon Aug 13, 2012 9:23 am
by IdeasVacuum
Is there a way to impose your own images instead of the system's images? (#MB_ICONWARNING etc)

Re: MessageRequester #MB_ICON

Posted: Tue Aug 14, 2012 5:12 am
by RASHAD
Hi
You can use any of the program icons (in the compiler options)
Or the dialogue icon by itself

Code: Select all

  #MB_USERICON = $080
  
  mb.MSGBOXPARAMS
  mb\cbSize = SizeOf(mb)
  mb\hwndOwner = 0
  mb\hInstance = GetModuleHandle_ (0)
  mb\lpszText = @"Test MBox"
  mb\lpszCaption = @"Message Title"
  mb\dwStyle = #MB_YESNOCANCEL|#MB_USERICON
  mb\lpszIcon = 1
  mb\dwContextHelpId = 0
  mb\lpfnMsgBoxCallback = 0
  mb\dwLanguageId = 0 


If OpenWindow(0, 0, 0, 400, 300, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

 MessageBoxIndirect_(mb) ;

  Repeat
    Event = WaitWindowEvent()

    If Event = #PB_Event_CloseWindow 
      Quit = 1
    EndIf

  Until Quit = 1
  
EndIf

End   

Re: MessageRequester #MB_ICON

Posted: Tue Aug 14, 2012 5:40 am
by jassing
RASHAD wrote:You can use any of the program icons (in the compiler options)
do you know if you can use an image included (includebinary) in the code?

Re: MessageRequester #MB_ICON

Posted: Tue Aug 14, 2012 5:52 am
by RASHAD
- Add as many icons as you can to the next script
- Remember to increase the ID 8001,8002,8003 and so on
- Save the file as "Icons.rc"
- Add the file to the resources in the compiler options
- Change the Req ID as you like (mb\lpszIcon = 8001)

Have fun

Code: Select all

// RESOURCE SCRIPT generated by "Pelles C for Windows, version 6.00".

// #include <windows.h>
// #include <commctrl.h>
// #include <richedit.h>

// LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

8001 ICON "G:\Projects\Icon\ActVista.ico"
8002 ICON "G:\Projects\Icon\CdPlayer.ico"


For TEST

Code: Select all

  #MB_USERICON = $080
  Global mb.MSGBOXPARAMS 
  
  mb\cbSize = SizeOf(mb)
  mb\hwndOwner = 0
  mb\hInstance = GetModuleHandle_ (0)
  mb\lpszText = @"Test MBox"
  mb\lpszCaption = @"Message Title"
  mb\dwStyle = #MB_YESNOCANCEL|#MB_USERICON
  mb\dwContextHelpId = 0
  mb\lpfnMsgBoxCallback = 0
  mb\dwLanguageId = 0

If OpenWindow(0, 0, 0, 400, 300, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

mb\lpszIcon = 8001
MessageBoxIndirect_(mb)

Delay(100)

mb\lpszIcon = 8002
MessageBoxIndirect_(mb) ;

  Repeat
    Event = WaitWindowEvent()

    If Event = #PB_Event_CloseWindow 
      Quit = 1
    EndIf

  Until Quit = 1
  
EndIf

End 


Re: MessageRequester #MB_ICON

Posted: Tue Aug 14, 2012 6:39 am
by jassing
Thank you Rashad! I keep forgetting about the resource-ability... I was so focused on "DataSection/INcludeBinary"...
Sadly; when I run (with valid icons set in the rc file)

Image

I recall there being "something" (I've used resources in pb previously) but it's late here and i'm drawing a blank.
but that is good stuff. THanks again!

Re: MessageRequester #MB_ICON

Posted: Tue Aug 14, 2012 12:29 pm
by IdeasVacuum
ooh that's a lovely solution Rashad 8)