Page 1 of 1

StartMenu like windows [Resolved]

Posted: Wed Feb 13, 2013 12:13 pm
by Kwai chang caine
Hello at all

Is it possible to create in a window a simple menu, like the startMenu of windows, in the left bottom of this window

Image

Thanks

Re: StartMenu like windows

Posted: Wed Feb 13, 2013 2:01 pm
by Kwai chang caine
I have found that
http://www.purebasic.fr/english/viewtop ... 56#p163456
But the menu move up to down, like all the normal menu :(
I search a menu who move down to up, like the startmenu of window

Re: StartMenu like windows

Posted: Wed Feb 13, 2013 6:25 pm
by RASHAD
Hi KCC

Code: Select all

Global menuImageWidth = GetSystemMetrics_(#SM_CXMENUCHECK)
Global menuImageHeight = GetSystemMetrics_(#SM_CYMENUCHECK)

CreateImage(0,30,30)
StartDrawing(ImageOutput(0))
  For x = 0 To 29
  For y = 0 To 29
    Plot(x,y, RGB(x,y,x*y))
  Next
Next
StopDrawing()

Procedure SetImage(iMenu, iID, ico)
  ExtractIconEx_("shell32.dll", ico, 0, @iIcon, 1)
  im=CreateImage(#PB_Any, 16, 16)
  himg = StartDrawing(ImageOutput(im))
  Box(0, 0, 16, 16, RGB(255, 255, 255))
  DrawImage(iIcon, 0, 0, 16, 16)
  StopDrawing()
  itemImage = ResizeImage(im, menuImageWidth, menuImageHeight)
  SetMenuItemBitmaps_(iMenu,iID,#MF_BYPOSITION,itemImage,0)
  DestroyIcon_(iIcon)
EndProcedure

OpenWindow(0, 0, 0, 600, 300, "TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SetWindowColor(0,$BCFCFD)
ContainerGadget(0,0,270,400,30,#PB_Container_Single)
ButtonImageGadget(1,2,0,30,30,ImageID(0))

hMenu = CreatePopupMenu(0)
MenuItem(0, "Testing 0")
MenuItem(1, "Testing 1")
sMenu = OpenSubMenu("Submenu")
MenuItem(2, "Testing 2")
MenuItem(3, "Testing 3")
MenuItem(4, "Testing 4")
MenuItem(5, "Testing 5")

SetImage(hMenu, 0, 4)
SetImage(hMenu, 1, 130)
SetImage(hMenu, 2, 194)
SetImage(sMenu, 0,4)
SetImage(sMenu, 1, 43)
SetImage(sMenu, 2, 10)
SetImage(sMenu, 3, 90)

Repeat
    Select WaitWindowEvent()
      Case #PB_Event_SizeWindow
           ResizeGadget(0,-2,WindowHeight(0)- 32,WindowWidth(0)+4,32)
           
      Case #PB_Event_Gadget
        Select EventGadget()
         Case 1
            DisplayPopupMenu(0, WindowID(0),WindowX(0)+GadgetX(0)+12, WindowY(0)+WindowHeight(0) - 70)           
        EndSelect         

      Case #PB_Event_Menu
        Select EventMenu()
          Case 0 : Debug "MenuItem #0"
          Case 1 : Debug "MenuItem #1"
          Case 2 : Debug "MenuItem #2"
          Case 3 : Debug "MenuItem #3"
          Case 4 : Debug "MenuItem #4"
          Case 5 : Debug "MenuItem #5"
          Case 6 : Debug "MenuItem #6"
        EndSelect
       
      Case #PB_Event_CloseWindow
        Quit = 1
       
    EndSelect
Until Quit = 1

Edit :Modified #1

Re: StartMenu like windows

Posted: Wed Feb 13, 2013 8:42 pm
by Kwai chang caine
Ouuuaaaaahhh !!!!
Thanks a lot my good RASHAD...your menu is splendid !!! :shock:
Exactely, what i want... 8)

I have try to begin one, but mine is with windows and horrible :oops:

I wish you a very very good night !!

Re: StartMenu like windows [Resolved]

Posted: Wed Feb 13, 2013 9:14 pm
by Lite
Hello

This example is great.
is it possible iconsize 32*32 and a larger text ?

Lite

Re: StartMenu like windows [Resolved]

Posted: Wed Feb 13, 2013 9:31 pm
by davido
Hi RASHAD,

Thanks for sharing another great code demo.

Re: StartMenu like windows [Resolved]

Posted: Wed Feb 13, 2013 10:45 pm
by RASHAD
Thanks guys
@Lite
If you want to change the font size ,style ,name
You need ownerdrawn PopUp Menu (Search the forum for ownerdrawn menu)

Next snippet for the image size 32*32

Code: Select all


CreateImage(0,60,30)
StartDrawing(ImageOutput(0))
  For x = 0 To 20
  For y = 0 To 29
    Plot(x,y, RGB(x,y,x*y))
  Next
  Next
  DrawText(24,6,"Start")
StopDrawing()

Procedure SetImage(iMenu, iID, ico)
  ExtractIconEx_("shell32.dll", ico, 0, @iIcon, 1)
  im=CreateImage(#PB_Any, 32, 32)
  StartDrawing(ImageOutput(im))
     Box(0, 0, 32, 32, GetSysColor_(#COLOR_MENU))
     DrawImage(iIcon, 0, 0, 32, 32)
  StopDrawing()
  SetMenuItemBitmaps_(iMenu,iID,#MF_BYPOSITION,ImageID(im),0)
  DestroyIcon_(iIcon)
EndProcedure

OpenWindow(0, 0, 0, 600, 300, "TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
SetWindowColor(0,$BCFCFD)
ContainerGadget(0,0,270,400,30,#PB_Container_Single)
ButtonImageGadget(1,2,0,60,30,ImageID(0))

hMenu = CreatePopupMenu(0)
MenuItem(0, "Testing 0")
MenuItem(1, "Testing 1")
sMenu = OpenSubMenu("Submenu")
MenuItem(2, "Testing 2")
MenuItem(3, "Testing 3")
MenuItem(4, "Testing 4")
MenuItem(5, "Testing 5")

SetImage(hMenu, 0, 4)
SetImage(hMenu, 1, 130)
SetImage(hMenu, 2, 194)
SetImage(sMenu, 0,4)
SetImage(sMenu, 1, 43)
SetImage(sMenu, 2, 10)
SetImage(sMenu, 3, 90)


Repeat
    Select WaitWindowEvent()
      Case #PB_Event_SizeWindow
           ResizeGadget(0,-2,WindowHeight(0)- 32,WindowWidth(0)+4,32)
           
      Case #PB_Event_Gadget
        Select EventGadget()
         Case 1
            DisplayPopupMenu(0, WindowID(0),WindowX(0)+GadgetX(0)+12, WindowY(0)+WindowHeight(0) - 120)           
        EndSelect         

      Case #PB_Event_Menu
        Select EventMenu()
          Case 0 : Debug "MenuItem #0"
          Case 1 : Debug "MenuItem #1"
          Case 2 : Debug "MenuItem #2"
          Case 3 : Debug "MenuItem #3"
          Case 4 : Debug "MenuItem #4"
          Case 5 : Debug "MenuItem #5"
          Case 6 : Debug "MenuItem #6"
        EndSelect
       
      Case #PB_Event_CloseWindow
        Quit = 1
       
    EndSelect
Until Quit = 1

Re: StartMenu like windows [Resolved]

Posted: Thu Feb 14, 2013 8:59 am
by Kwai chang caine
Cool !!! again more nice :shock:
PerhapsImagetake your for the W9 :D

Hummmmmm !!! and if i want to recreate a full window operating system..... :idea:
W8 is not fun...why not KCC8 ?? .....can i ask to you for help ?? :mrgreen: :lol: :lol: :lol: :lol:

If i say "I love you" surelly you are affraid, like several members in this forum :oops: ....so this time, Kcc have understand... he say nothing, but the heart is :wink:
Again thanks RASHAD for your precious and numerous helps, your generosity, your big knowledge and have a very good day 8)