Announcement

Collapse
No announcement yet.

bitmap in menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    Saving the bitmaps in the menus for version 2.0?

    That's actually a pretty good plan:

    First you make it work; only then do you make it work better.

    MCM

    Leave a comment:


  • david thain
    replied
    menu with bitmap

    Here is the working product, compliments to Michael Mattias.
    Resource:
    Code:
    #include "resource.h"
    
    #define IDC_EDT1 2001
    #define IDC_STC1 2002
    #define IDC_BTN1 2003
    #define IDC_BTN2 2004
    
    #define IDM_Update  1000
    #define IDM_Dbgrid  1002
    #define IDM_Rename  1003
    #define IDM_Reconsile  1011
    #define IDM_Outstnd  1012
    #define IDM_Scntls  1013
    #define IDM_EXIT  1004
    #define idb_bitmap 100
    #define IDC_IMG1 1005
    
    ck001 MENU
    
    {
     POPUP "&File"
     {
      MENUITEM "&Update...",               IDM_Update
      MENUITEM "&Dbgrid...",               IDM_Dbgrid
      MENUITEM "&Rename...",               IDM_Rename
    
      MENUITEM SEPARATOR
      MENUITEM "&Exit",                  IDM_EXIT
     }
     POPUP "&Reports"
     {
      MENUITEM "&Reconsile...",            IDM_Reconsile
      MENUITEM "&Outstnd...",              IDM_Outstnd
      MENUITEM "&Scntls...",               IDM_Scntls
     }
    
    }
    
    dialog_1 DIALOGEX 226,226,279,375
    CAPTION "                           Picture Test"
    FONT 8,"MS Sans Serif",0,0
    STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |WS_SYSMENU
    
    MENU ck001
    
    BEGIN
      CONTROL "",IDC_EDT1,"Edit",0x50010000,14,48,254,13,0x00000200
      CONTROL "File Name",IDC_STC1,"Static",0x50000000,32,31,70,9
      CONTROL "Change",IDC_BTN1,"Button",0x50010000,38,72,62,13
      CONTROL "Exit",IDC_BTN2,"Button",0x50010000,218,72,44,13
      CONTROL "#100",IDC_IMG1,"Static",0x5000020E,40,114,212,249
    END
    idb_bitmap BITMAP DISCARDABLE "C:/piclib/walmart3/walmart3-069.bmp"
    Program :

    Code:
    ' ck001.bas
    ' djt
    ' program general menu
    #COMPILE EXE
    #CONSOLE OFF
    #INCLUDE "Win32API.inc"
    
    #RESOURCE "ck001.pbr"
    
    %IDM_Update     =  1000
    %IDM_Dbgrid     =  1002
    %IDM_Rename     =  1003
    %IDM_Reconsile  =  1011
    %IDM_Outstnd    =  1012
    %IDM_Scntls     =  1013
    %IDC_BTN1       =  2003
    %IDC_BTN2       =  2004
    %IDC_EDT1       =  2001
    %IDM_EXIT       =  1004
    
    $exename1 = "c:\accounts\cnbdt\ck001\ck002.exe"  'update records
    $exename2 = "c:\accounts\cnbdt\ck001\ck004.exe" 'reconsiled report
    $exename3 = "c:\accounts\cnbdt\ck001\ck005.exe" 'outstanding report
    $exename4 = "c:\accounts\cnbdt\ck001\ck007.exe" 'totals to screen
    $exename5 = "c:\accounts\cnbdt\ck001\dbgrid.exe" 'scroll file
    $exename6 = "c:\accounts\cnbdt\ck001\ck013.exe" 'change name of file
    $exename7 = "c:\accounts\cnbdt\ck001\ck006.exe" 'acctno totals
    %cmdline = 1
    
    GLOBAL varble$()
    GLOBAL infofle$
    GLOBAL conam$,lb1$, flena1$, lb2$, flena2$, fleno%, dr$
    
    
    DECLARE FUNCTION DialogBox (BYVAL hCurInstance AS LONG, lpTemplateName AS ASCIIZ, BYVAL hWndParent AS LONG, BYVAL lpDialogFunc AS LONG) AS LONG
    DECLARE FUNCTION DlgProc(BYVAL hDlg AS LONG, BYVAL uMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    
    FUNCTION WINMAIN (BYVAL hCurInstance  AS LONG, _     'Not PBMain since
                      BYVAL hPrevInstance AS LONG, _     'hCurInstance is needed
                      BYVAL lpszCmdLine         AS ASCIIZ PTR, _
                      BYVAL nCmdShow AS LONG ) EXPORT AS LONG
        DEFINT a-z
        numfles%=1
        numflds%=12
        DIM varble$(11)
    
        infofle$ = "c:\accounts\cnbdt\ck001.dss"
        OPEN infofle$ FOR INPUT AS 1
        INPUT #1, conam$, lb1$, flena1$, lb2$, flena2$, fleno%, dr$
    
        CLOSE 1
    
        varble$(1)=flena2$
    
        DialogBox hCurInstance, "DIALOG_1", hconsole, CODEPTR(DlgProc)
    
    
    END FUNCTION
    
    
    FUNCTION DlgProc(BYVAL hDlg AS LONG, BYVAL uMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
        DIM id AS LONG
        DIM event AS LONG
        DIM x AS LONG
        DIM y AS LONG
        DIM hBtn AS LONG
        DIM rc AS RECT
        LOCAL buffer AS ASCIIZ * 45
    
        SELECT CASE uMsg
            CASE %WM_INITDIALOG
                buffer=varble$(1)
                setdlgitemtext(hdlg,%IDC_EDT1,buffer)  'put text in textbox
    
    
            CASE %WM_CLOSE
                CLOSE 1
                EndDialog(hDlg, 0)
    
            CASE %WM_COMMAND
                id=LOWRD(wParam)
                event=HIWRD(wParam)
    
                SELECT CASE id
                    CASE %IDM_Update
                        result = SHELL( $exename1, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %IDM_Dbgrid
                        result = SHELL( $exename5, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %IDM_Rename
                        result = SHELL( $exename6, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %IDM_Reconsile
                        result = SHELL( $exename2, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %IDM_Outstnd
                        result = SHELL( $exename3, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %IDM_Scntls
                        result = SHELL( $exename4, %cmdline )
                        IF result = -1 THEN
                            BEEP
                        END IF
    
                    CASE %idcancel 'esc keydown
                        EndDialog( hDlg, NULL )
                        
                    CASE %IDC_BTN2 'exit button
                        EndDialog( hDlg, NULL )
                                                          
                    CASE %IDM_EXIT   'menu exit
                        CLOSE 1
                        EndDialog(hDlg, 0)
    
                    CASE %IDC_BTN1  'Get text from screen
                        GetDlgItemtext(hdlg,%IDC_EDT1,buffer,45)
                        varble$(1)= buffer
    
                        flena2$=varble$(1)
                        OPEN infofle$ FOR OUTPUT AS 1
                        WRITE #1, conam$, lb1$, flena1$, lb2$, flena2$, fleno%, dr$
                        CLOSE 1
    
                END SELECT
    
    
            CASE WM_SIZE
    '           GetClientRect(hDlg,@rect)
    '           hBtn=GetDlgItem(hDlg,IDD_dlg1)
    '           x=rect.right-100
    '           y=rect.bottom-35
    '           MoveWindow(hBtn,200,255,497,431,TRUE)
    
    
        END SELECT
    
    END FUNCTION
    
    FUNCTION DialogBox (BYVAL hCurInstance AS LONG, lpTemplateName AS ASCIIZ, BYVAL hWndParent AS LONG, BYVAL lpDialogFunc AS LONG) AS LONG
      FUNCTION = DialogBoxParam(hCurInstance, lpTemplateName, hWndParent, lpDialogFunc, 0)
    END FUNCTION
    djt

    Leave a comment:


  • Michael Mattias
    replied
    1. You simply must start using Code Tags when posting code. I even go so far as to suggest to edit your previous posts in this thread to insert them so we can read what you have done.

    2. If you want your dialog to have a menu, the straightforward way to do that is to use the MENU statement in the dialog template, eg...
    Code:
    dialog_1 DIALOGEX 226,226,279,375
    CAPTION " Picture Test"
    FONT 8,"MS Sans Serif",0,0
    STYLE 0x10CF0000
    [b]MENU menuname[/b]
    BEGIN
      {controls}
      ...
    END
    Details in the resource compiler help file installed with the compiler.

    Just for style points (pun not intended)
    Code:
    STYLE 0x10CF0000
    Inline numeric literals ("magic numbers") are a bad habit. Use the symbolic style names combined with the OR operator, eg..
    Code:
    STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |WS_SYSMENU
    That's a little easier to understand and debug, no? You'll have to #include resource.h (also supplied with compiler) in your resource script file.

    3.
    If I were to use this resource file in the program above (with a few name changes) , I would get a Menu but no Picture??
    What happened when you tried? (You did try it, right?)

    Leave a comment:


  • david thain
    replied
    Another program

    Here is another program that shows the Picture but not the Menu. If I were to use this resource file in the program above (with a few name changes) , I would get a Menu but no Picture??

    #include "resource.h"
    #define IDD_DLG1 1000
    #define IDC_EDT1 1001
    #define IDC_STC1 1002
    #define IDC_BTN1 1003
    #define IDC_BTN2 1004
    #define idb_bitmap 100
    #define IDC_IMG1 1005

    #define IDM_Update 2000
    #define IDM_Dbgrid 2002
    #define IDM_Rename 2003
    #define IDM_Reconsile 2011
    #define IDM_Outstnd 2012
    #define IDM_Scntls 2013
    #define IDM_EXIT 2004

    test4 MENU
    {
    POPUP "&File"
    {
    MENUITEM "&Update...", IDM_Update
    MENUITEM "&Dbgrid...", IDM_Dbgrid
    MENUITEM "&Rename...", IDM_Rename

    MENUITEM SEPARATOR
    MENUITEM "E&xit", IDM_EXIT
    }
    POPUP "&Reports"
    {
    MENUITEM "&Reconsile...", IDM_Reconsile
    MENUITEM "&Outstnd...", IDM_Outstnd
    MENUITEM "&Scntls...", IDM_Scntls
    }

    }

    dialog_1 DIALOGEX 226,226,279,375
    CAPTION " Picture Test"
    FONT 8,"MS Sans Serif",0,0
    STYLE 0x10CF0000

    BEGIN
    CONTROL "",IDC_EDT1,"Edit",0x50010000,14,48,254,13,0x00000200
    CONTROL "File Name",IDC_STC1,"Static",0x50000000,32,31,70,9
    CONTROL "Change",IDC_BTN1,"Button",0x50010000,38,72,62,13
    CONTROL "Exit",IDC_BTN2,"Button",0x50010000,218,72,44,13
    CONTROL "#100",IDC_IMG1,"Static",0x5000020E,40,114,212,249
    END
    idb_bitmap BITMAP DISCARDABLE "C:/piclib/walmart3/walmart3-069.bmp"

    '*******************************************************

    ' ck013.bas
    ' djt
    ' program changes name of file
    #COMPILE EXE
    #CONSOLE OFF
    #INCLUDE "Win32API.inc"

    #RESOURCE "test4.pbr"
    #INCLUDE "c:\develop\pbcc\pbcca3\foxit12.inc"

    GLOBAL varble$()
    DECLARE FUNCTION DialogBox (BYVAL hCurInstance AS LONG, lpTemplateName AS ASCIIZ, BYVAL hWndParent AS LONG, BYVAL lpDialogFunc AS LONG) AS LONG
    DECLARE FUNCTION DlgProc(BYVAL hDlg AS LONG, BYVAL uMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG

    FUNCTION WINMAIN (BYVAL hCurInstance AS LONG, _ 'Not PBMain since
    BYVAL hPrevInstance AS LONG, _ 'hCurInstance is needed
    BYVAL lpszCmdLine AS ASCIIZ PTR, _
    BYVAL nCmdShow AS LONG ) EXPORT AS LONG
    DEFINT a-z
    numfles%=1
    numflds%=12
    DIM varble$(11)

    #INCLUDE "c:\develop\pbcc\pbcca3\foxitdim.inc"

    infofle$ = "c:\accounts\cnbdt\ck001.dss"
    OPEN infofle$ FOR INPUT AS 1
    INPUT #1, conam$, lb1$, flena1$, lb2$, flena2$, fleno%, dr$

    CLOSE 1

    varble$(1)=flena2$

    DialogBox hCurInstance, "DIALOG_1", hconsole, CODEPTR(DlgProc)

    flena2$=varble$(1)
    OPEN infofle$ FOR OUTPUT AS 1
    WRITE #1, conam$, lb1$, flena1$, lb2$, flena2$, fleno%, dr$
    CLOSE 1
    END FUNCTION


    FUNCTION DlgProc(BYVAL hDlg AS LONG, BYVAL uMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    DIM id AS LONG
    DIM event AS LONG
    DIM x AS LONG
    DIM y AS LONG
    DIM hBtn AS LONG
    DIM rc AS RECT
    LOCAL buffer AS ASCIIZ * 45

    SELECT CASE uMsg
    CASE %WM_INITDIALOG
    buffer=varble$(1)
    setdlgitemtext(hdlg,1001&,buffer) 'put text in textbox


    CASE %WM_CLOSE
    CLOSE 1
    EndDialog(hDlg, 0)
    '
    CASE %WM_COMMAND
    id=LOWRD(wParam)
    event=HIWRD(wParam)

    SELECT CASE id

    CASE %idcancel 'esc keydown
    EndDialog( hDlg, NULL )

    CASE 1004 'exit button
    CLOSE 1
    EndDialog(hDlg, 0)

    CASE 1003 'Get text from screen
    GetDlgItemtext(hdlg,1001&,buffer,45)
    varble$(1)= buffer
    END SELECT


    CASE WM_SIZE
    ' GetClientRect(hDlg,@rect)
    ' hBtn=GetDlgItem(hDlg,IDD_dlg1)
    ' x=rect.right-100
    ' y=rect.bottom-35
    ' MoveWindow(hBtn,200,255,497,431,TRUE)


    END SELECT

    END FUNCTION

    FUNCTION DialogBox (BYVAL hCurInstance AS LONG, lpTemplateName AS ASCIIZ, BYVAL hWndParent AS LONG, BYVAL lpDialogFunc AS LONG) AS LONG
    FUNCTION = DialogBoxParam(hCurInstance, lpTemplateName, hWndParent, lpDialogFunc, 0)
    END FUNCTION

    Leave a comment:


  • Michael Mattias
    replied
    Here's an example of adding Menu items to a menu using those functions with a menu defined in a resource script.

    Add a 'Favorite Files' menu to your application 10-25-07

    What I did here was define the popup menu (the one that drops down from the main menu bar) in the resource file with only the "constant" menu items, and I added the other items on the fly.

    You can do the same thing, specifying style MF_BITMAP when you add those menu items which use bitmaps.

    MCM

    Leave a comment:


  • Michael Mattias
    replied
    >Is there a way to display a bitmap picture on the face of a menu...

    Yes.

    >..using the following .bas & .rc files?

    I don't think so.

    I can't see in the resource compiler help file (should be on your PB/CC program menu) that you can define a MF_BITMAP type MENUITEM in your resource script.

    That means you will have to create the menu yourself in code using the WinAPI menu functions. Those functions are ...

    CreatePopupMenu (to create the Popup menu which drops down from the main menu bar)
    and
    InsertMenu or AppendMenu (your choice) to add menu items with style MF_BITMAP, or to associate the new popup menu with the main menu bar.

    There 'should' be examples here in the source code forum, somewhere. If not, those WinAPI functions are pretty simple ones to use and I know they work because I've used them many times.

    MCM

    Leave a comment:


  • david thain
    started a topic bitmap in menu

    bitmap in menu

    Is there a way to display a bitmap picture on the face of a menu using the following .bas & .rc files?

    //ck001.rc
    #include "resource.h"

    #define IDM_Update 1000
    #define IDM_Dbgrid 1002
    #define IDM_Rename 1003
    #define IDM_Reconsile 1011
    #define IDM_Outstnd 1012
    #define IDM_Scntls 1013
    #define IDM_EXIT 1004


    ck001 MENU
    {
    POPUP "&File"
    {
    MENUITEM "&Update...", IDM_Update
    MENUITEM "&Dbgrid...", IDM_Dbgrid
    MENUITEM "&Rename...", IDM_Rename

    MENUITEM SEPARATOR
    MENUITEM "E&xit", IDM_EXIT
    }
    POPUP "&Reports"
    {
    MENUITEM "&Reconsile...", IDM_Reconsile
    MENUITEM "&Outstnd...", IDM_Outstnd
    MENUITEM "&Scntls...", IDM_Scntls
    }

    }

    '*******************************************************

    'ck001.bas
    #COMPILE EXE
    #CONSOLE OFF
    #INCLUDE "Win32api.inc"
    #RESOURCE "ck001.pbr"

    %IDM_Update = 1000
    %IDM_Dbgrid = 1002
    %IDM_Rename = 1003
    %IDM_EXIT = 1004
    %IDM_Reconsile = 1011
    %IDM_Outstnd = 1012
    %IDM_Scntls = 1013

    $exename1 = "c:\accounts\cnbdt\ck001\ck002.exe" 'update records
    $exename2 = "c:\accounts\cnbdt\ck001\ck004.exe" 'reconsiled report
    $exename3 = "c:\accounts\cnbdt\ck001\ck005.exe" 'outstanding report
    $exename4 = "c:\accounts\cnbdt\ck001\ck007.exe" 'totals to screen
    $exename5 = "c:\accounts\cnbdt\ck001\dbgrid.exe" 'scroll file
    $exename6 = "c:\accounts\cnbdt\ck001\ck013.exe" 'change name of file
    $exename7 = "c:\accounts\cnbdt\ck001\ck006.exe" 'acctno totals
    %cmdline = 1



    FUNCTION WndProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    SELECT CASE AS LONG wMsg
    CASE %WM_CREATE
    DIM result AS INTEGER
    LOCAL hInst AS DWORD


    CASE %WM_COMMAND
    SELECT CASE LOWRD(wParam)
    CASE %IDM_Update
    result = SHELL( $exename1, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF


    CASE %IDM_Dbgrid

    result = SHELL( $exename5, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF

    CASE %IDM_Rename
    result = SHELL( $exename6, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF

    CASE %IDM_Reconsile
    result = SHELL( $exename2, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF

    CASE %IDM_Outstnd
    result = SHELL( $exename3, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF

    CASE %IDM_Scntls
    result = SHELL( $exename4, %cmdline )
    IF result = -1 THEN
    BEEP
    END IF

    CASE %IDM_EXIT
    PRINT "Send A Message To Windows To Close The Application."
    CALL SendMessage(hWnd,%WM_CLOSE,0,0)

    END SELECT
    WndProc=0
    EXIT FUNCTION
    CASE %WM_CLOSE
    CALL DestroyWindow(hWnd)
    ' END IF
    WndProc=0
    EXIT FUNCTION
    CASE %WM_DESTROY
    CALL PostQuitMessage(0)
    WndProc=0
    EXIT FUNCTION
    END SELECT

    WndProc=DefWindowProc(hWnd,wMsg,wParam,lParam)
    END FUNCTION


    FUNCTION WINMAIN(BYVAL hIns AS LONG, BYVAL hPrev AS LONG,BYVAL lpCL AS ASCIIZ PTR, BYVAL IS AS LONG) AS LONG

    LOCAL winclass AS WndClassEx
    LOCAL szAppName AS ASCIIZ*8
    LOCAL hMainWnd AS DWORD
    LOCAL Msg AS tagMsg




    szAppName="ck001"
    winclass.lpszClassName=VARPTR(szAppName) : winclass.lpfnWndProc=CODEPTR(WndProc)
    winclass.cbSize=SIZEOF(winclass) : winclass.style=%CS_HREDRAW OR %CS_VREDRAW
    winclass.cbClsExtra=0 : winclass.cbWndExtra=0
    winclass.hInstance=hIns : winclass.hIcon=LoadIcon(%NULL,BYVAL %IDI_APPLICATION)
    winclass.hCursor=LoadCursor(%NULL, BYVAL %IDC_ARROW) : winclass.hbrBackground=%COLOR_BTNFACE+1
    winclass.lpszMenuName=VARPTR(szAppName) : winclass.hIconSm=LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
    CALL RegisterClassEx(winclass)
    hMainWnd=CreateWindowEx(0,szAppName," Check Account ",%WS_OVERLAPPEDWINDOW,250,140,525,325,0,0,hIns,BYVAL 0)
    ShowWindow hMainWnd,IS
    UpdateWindow hMainWnd
    WHILE GetMessage(Msg,%NULL,0,0)
    CALL TranslateMessage(Msg)
    CALL DispatchMessage(Msg)
    WEND

    FUNCTION=msg.wParam
    END FUNCTION
Working...
X