Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

PBedit Combobox widener..

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

  • PBedit Combobox widener..

    Code:
    ' Simple hack that enumerates running app's, looks for PBedit and
    ' enumerates it's childs. If combobox is found, you can use the
    ' buttons to set/reset the width of its dropdown list.
    '
    ' Works fine in my Win98 - No guarantees for other systems.
    ' Public Domain, April 2001 by Borje Hagsten.
    ' Free to use and modify, but as always - at your own responsibility..
    '
    ' Ideas: expand with other stuff. Maybe possible to add menu items,
    ' change captions, add stuff and functionalities, I don't know. Just
    ' wrote it and haven't started playing around with it yet. One idea would
    ' be to skip the buttons, add a shell command and start PBedit via
    ' this one, change the Combobox width and then close this one when done.
    ' Whatever - your own imagination is only limit..    [img]http://www.powerbasic.com/support/forums/smile.gif[/img]
    '
    ' Tip - to get a menu handle, one can use, hMenu = GetMenu(fhWnd) ...
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Declares
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
     
    GLOBAL fhWnd AS LONG, cbhWnd AS LONG, cbw AS LONG
    GLOBAL wTitle AS STRING
     
    DECLARE CALLBACK FUNCTION DlgProc() AS LONG
    DECLARE FUNCTION EnumWindowsProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG
    DECLARE FUNCTION EnumChildsProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Create dialog and controls, etc
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN () AS LONG
     LOCAL hDlg AS LONG
     
      DIALOG NEW 0, "PBedit Combo widener..",,, 195, 23, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
      CONTROL ADD BUTTON, hDlg, 10, "Set wider CB",    4, 4, 60, 14, %WS_TABSTOP
      CONTROL ADD BUTTON, hDlg, 11, "Reset CB width", 64, 4, 60, 14, %WS_TABSTOP
      CONTROL ADD BUTTON, hDlg, 12, "E&xit",         130, 4, 60, 14, %WS_TABSTOP
     
      EnumWindows CODEPTR(EnumWindowsProc), 0                           'enumerate running app's
      IF fhWnd THEN EnumChildWindows fhWnd, CODEPTR(EnumChildsProc), 0  'if PBedit was found, look for combobox
      IF cbhWnd THEN cbw = SendMessage(cbhWnd, %CB_GETDROPPEDWIDTH, 0, 0) 'if cb was found, store its drop width
     
      DIALOG SHOW MODAL hDlg CALL DlgProc
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc() AS LONG
      IF CBMSG = %WM_COMMAND THEN
         IF CBCTL = 10 THEN
            IF cbhWnd THEN
               LOCAL tmp AS LONG
               tmp = SendMessage(cbhWnd, %CB_GETDROPPEDWIDTH, 0, 0)
               IF tmp THEN
                  SendMessage cbhWnd, %CB_SETDROPPEDWIDTH, tmp + 60, 0
                  'tmp = GetStockObject(%ANSI_VAR_FONT) 'uncomment these two if you want narrower font
                  'SendMessage cbhWnd, %WM_SETFONT, tmp, -1
                  MSGBOX "Ok, now you can check your PBedit combo.."
               END IF
            ELSE
               MSGBOX "Sorry, no PBedit Combobox hWnd awailable"
            END IF
     
         ELSEIF CBCTL = 11 THEN
            IF cbhWnd THEN
               SendMessage cbhWnd, %CB_SETDROPPEDWIDTH, cbw, 0
            ELSE
               MSGBOX "Sorry, no PBedit Combobox hWnd awailable"
            END IF
     
         ELSEIF CBCTL = 12 THEN
            DIALOG END CBHNDL
         END IF
      END IF
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Enumerate running app's
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION EnumWindowsProc(BYVAL hwnd AS LONG, BYVAL lParam AS LONG) AS LONG
      wTitle = STRING$(256, 0)
      GetWindowText hwnd, BYVAL STRPTR(wTitle), 256  'Get window title
      wTitle = EXTRACT$(wTitle, CHR$(0))
     
      IF LEN(wTitle) THEN                  'compare title to find PBedit
         IF LEFT$(wTitle, 42) = "PowerBASIC 32-bit DLL Compiler for Windows" THEN
            fhWnd = hwnd                   '<- store its handle
            FUNCTION = 0 : EXIT FUNCTION   '<- break action
         END IF
      END IF
      FUNCTION = 1                         '<- reurn a valu to keep on looking
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Enumerate child's of given handle
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION EnumChildsProc(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG
        DIM clName AS ASCIIZ * 100
        GetClassName hWnd, clName, SIZEOF(clName) '<- what kind of control is it?
        clName = UCASE$(clName)
        IF clName = "COMBOBOX" THEN               '<- if COMBOBOX, then
           cbhWnd = hWnd                          '<- store it's handle
           FUNCTION = 0 : EXIT FUNCTION           '<- return 0 to breakl action
        END IF                                    '(be careful in other programs, other uses - but
                                                  ' PBedit only has one Combobox, so we're ok here..)
        FUNCTION = 1
    END FUNCTION
    ------------------
    Added code to set font in PBedit's combo. Commented out,
    so uncomment to see how it works..



    [This message has been edited by Borje Hagsten (edited April 06, 2001).]
Working...
X