MessageRequester #MB_ICON

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

MessageRequester #MB_ICON

Post by IdeasVacuum »

Is there a way to impose your own images instead of the system's images? (#MB_ICONWARNING etc)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: MessageRequester #MB_ICON

Post 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   
Egypt my love
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: MessageRequester #MB_ICON

Post 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?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: MessageRequester #MB_ICON

Post 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 

Egypt my love
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: MessageRequester #MB_ICON

Post 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!
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: MessageRequester #MB_ICON

Post by IdeasVacuum »

ooh that's a lovely solution Rashad 8)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply