Guidance
指路人
g.yi.org
software / rapidq / examples / GUI / StatusBar / StatusBitmaps / STATUSBITMAPS.RQB

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' BILL K   12-2002  StatusBitmaps.rqb
' This demonstrates how to make Bitmaps appear
'   in a QStatusbar very easily.
' This has four LED style indicators in the
'   statusbar that indicate Capslock, Insert Mode,
'   Numlock On, and Richedit.modified status.
' This also shows how to adjust the width
'   of a statusbar.panel() depending on the text
'  that it's displaying.
' I would appreciate any suggestions
'   Enjoy!  Bill K
'
' NOTE: This relies on having the required
'  eight 44 x 13 bitmap images for loading in
'  the program. One for each On/OFF status
'  of each LED.
'
     $OPTIMIZE ON
     $APPTYPE GUI
     $TYPECHECK ON
     $INCLUDE "C:\RAPIDQ\DEBUG2.INC"
'
'DECLARE CONSTANTS=================
     CONST CRLF=CHR$(13) & CHR$(10)
     CONST GWL_STYLE AS LONG = (-16)
     CONST VK_CAPITAL = &H14
     CONST VK_NUMLOCK = &H90
     CONST VK_INSERT = &H2D

'DECLARE VARIABLES===================
     DEFSTR CURSPRV
     DEFBYTE MODPREV,CAPSPREV,NUMPREV,INSRTSTAT
'
'DECLARE SUBS=======================
     DECLARE SUB DOTIMER
     DECLARE SUB DOINIT
     DECLARE SUB DORESIZE
     DECLARE SUB INSERTSTAT(key AS BYTE,shift AS BYTE)
'
'DECLARE FUNCTIONS==================
     DECLARE FUNCTION SetWindowLong LIB "User32" ALIAS _
      "SetWindowLongA" (hwnd AS LONG, nIndex AS LONG, _
      dwNewLong AS LONG) AS LONG
     DECLARE FUNCTION GetWindowLong LIB "user32" ALIAS _
      "GetWindowLongA"(hwnd AS LONG, nIndex AS LONG) AS LONG
     DECLARE FUNCTION SetParent LIB "user32" ALIAS _
      "SetParent" (hWndChild AS LONG, hWndNewParent _
      AS LONG) AS LONG
     DECLARE FUNCTION GetKeyState LIB "user32" ALIAS _
      "GetKeyState" (nVirtKey AS LONG) AS INTEGER
'
'===========
     CREATE TIMEX AS QTIMER
      INTERVAL=50
      ONTIMER=DOTIMER
     END CREATE
'
     CREATE RFONT AS QFONT
      NAME="LETTER GOTHIC"
      SIZE=10
     END CREATE
     CREATE BFONT AS QFONT
      NAME="ARIAL"
      SIZE=10
      BOLD=1
     END CREATE
     CREATE SBFONT AS QFONT
      NAME="ARIAL"
      SIZE=8
      BOLD=1
     END CREATE
'{===========FORMS================
     CREATE FORM AS QFORM '
      CAPTION="STATUSBAR BITMAPS DEMO"
      ONSHOW =DOINIT
      Width = 490
      Height = 520
      Center
      CREATE MenuBar1 AS QMAINMENU
       CREATE FileMenu AS QMENUITEM
        CAPTION = "&File"
       END CREATE
       CREATE EditMenu AS QMENUITEM
        CAPTION = "&Edit"
       END CREATE
       CREATE ToolsMenu AS QMENUITEM
        CAPTION = "&Tools"
       END CREATE
       CREATE HelpMenu AS QMENUITEM
        CAPTION = "&Help"
       END CREATE
      END CREATE 'MenuBar1
      CREATE REdit AS QRICHEDIT
       Left = 0
       Top = 89
       Width = 532
       Height = 382
       Align = 5
       FONT=RFONT
       ONKEYDOWN=insertstat
       HideSelection = 0
       PlainText = 1
       ScrollBars = 3
       WantTabs = 1
       TabOrder = 0
      END CREATE
      CREATE StatusBar AS QSTATUSBAR
       ADDPANELS "","",""
       Panel(0).Width = 185
       Panel(1).Width = 180
       Panel(2).CAPTION="C:\RapidQ\Examples\zipview.rqb"
      END CREATE
      CREATE STPANEL AS QPANEL
   ' you got to have bitmaps available before compile !
       HEIGHT=StatusBar.HEIGHT-5
       BEVELOUTER=0
       TOP=4
       CREATE IMAGE1 AS QIMAGE
        TRANSPARENT=1
        LEFT=0
        BMP="C:\RapidQ\BMP\INSERTONsq.BMP"
       END CREATE
       CREATE IMAGE2 AS QIMAGE
        TRANSPARENT=1
        LEFT=44
        BMP="C:\RapidQ\BMP\CAPSONsq.BMP"
       END CREATE
       CREATE IMAGE3 AS QIMAGE
        TRANSPARENT=1
        LEFT=88
        BMP="C:\RapidQ\BMP\NUMONsq.BMP"
       END CREATE
       CREATE IMAGE4 AS QIMAGE
        TRANSPARENT=1
        LEFT=132
        BMP="C:\RapidQ\BMP\SAVEDsq.BMP"
       END CREATE
      END CREATE
     END CREATE  ' FORM
'{==================SUBROUTINES==================
     SUB DOINIT
      DEFLNG STYLE
      FORM.FONT=SBFONT  ' Gives the StatusBar the attribute
'         of the FORM font
'===========================
' HERE'S THE BILL K PARENTING TRICK ! --  :-)
      style = GetWindowLong(Stpanel.handle, GWL_STYLE)
      SetWindowLong Stpanel.handle, GWL_STYLE,style
      SetParent Stpanel.Handle , Statusbar.Handle
'===========================
      STPANEL.WIDTH=StatusBar.PANEL(1).WIDTH - 4
     END SUB
'
     SUB INSERTSTAT(KEY,SHIFT)
      DEFBYTE KEYST
      IF KEY=45 AND SHIFT=0 THEN
       INSRTSTAT=1-INSRTSTAT
       IF INSRTSTAT=0 THEN
        IMAGE1.BMP="C:\RAPIDQ\BMP\INSERTONSQ.BMP"
       ELSE
        IMAGE1.BMP="C:\RAPIDQ\BMP\INSERTOFFSQ.BMP"
       END IF
      END IF
     END SUB
'
     SUB DOTIMER
      DEFSTR CAPSTR,CURSTR
      CURSTR=STR$(REDIT.WHEREY+1) & " : " & _
       STR$(REDIT.WHEREX+1) _
       & " / " &  STR$(REDIT.LINECOUNT) & _
       " Lines, Size=" & STR$(LEN(REDIT.text))
      IF CURSPRV<>CURSTR THEN
       CURSPRV=CURSTR
       StatusBar.PANEL(0).CAPTION=CURSTR
       StatusBar.PANEL(0).WIDTH=FORM.TEXTWIDTH(CURSTR)+6
       STPANEL.LEFT=StatusBar.PANEL(0).WIDTH + 3
      END IF
      IF MODPREV<>REDIT.MODIFIED THEN
       MODPREV=REDIT.MODIFIED
       IF REDIT.MODIFIED THEN
        IMAGE4.BMP="C:\RapidQ\BMP\MODIFYsq.BMP"
       ELSE
        IMAGE4.BMP="C:\RapidQ\BMP\SAVEDsq.BMP"
       END IF
      END IF
      IF CAPSPREV<>GetKeyState(VK_CAPITAL) OR _
       NUMPREV<>GetKeyState(VK_NUMLOCK) THEN
       CAPSPREV=GetKeyState(VK_CAPITAL)
       NUMPREV=GetKeyState(VK_NUMLOCK)
       IF CAPSPREV THEN
        IMAGE2.BMP="C:\RapidQ\BMP\CAPSONsq.BMP"
       ELSE
        IMAGE2.BMP="C:\RapidQ\BMP\CAPSOFFsq.BMP"
       END IF
       IF NUMPREV THEN
        IMAGE3.BMP="C:\RapidQ\BMP\NUMONsq.BMP"
       ELSE
        IMAGE3.BMP="C:\RapidQ\BMP\NUMOFFsq.BMP"
       END IF
      END IF
     END SUB
'{===================INITIALIZE CODE======
'========================================
'-So Main Form Minimizes Correctly--------
     SetWindowLong FORM.HANDLE, -8, 0
     SetWindowLong application.HANDLE, -8, FORM.HANDLE
'----------------
     FORM.SHOWMODAL
' end

掌柜推荐
 
 
¥900.00 ·
 
 
¥291.00 ·
 
 
¥1,580.00 ·
 
 
¥307.00 ·
 
 
¥1,390.00 ·
 
 
¥1,380.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:56:18