' Advanced Techniques for Rapid-Q by William Yu ' -- How to create your own custom look-&-feel forms! ' ' What makes this so complicated is because you have to write your own ' resize handlers! Since we're using a borderless form, we can pretty much ' make it look like anything we want. Instead of the traditional title on ' the top of the form, you can have it on the bottom, the left, or right! $INCLUDE "RAPIDQ.INC" $TYPECHECK ON $APPTYPE GUI $RESOURCE BMP_CLOSE AS "CLOSE.BMP" $RESOURCE BMP_MIN AS "MIN.BMP" $RESOURCE BMP_MAX AS "MAX.BMP" $RESOURCE BMP_HELP AS "HELP.BMP" '$RESOURCE BMP_IMAGE AS "C:\WINDOWS\CLOUDS.BMP" DIM MainForm AS QForm DIM PanelR AS QPanel, PanelL AS QPanel, PanelD AS QPanel, PanelU AS QPanel DIM PanelDL AS QPanel, PanelDDL AS QPanel DIM PanelDR AS QPanel, PanelDDR AS QPanel DIM PanelUL AS QPanel, PanelUUL AS QPanel DIM PanelUR AS QPanel, PanelUUR AS QPanel DIM MainPanel AS QPanel DIM TitlePanel AS QPanel DIM Image AS QImage DIM Font AS QFont Font.Name = "Arial" Font.Size = 10 Font.Color = &HFFFFFF DIM CloseButton AS QButton, MinButton AS QCoolBtn DIM MaxButton AS QCoolBtn, HelpButton AS QCoolBtn DIM DownX AS INTEGER, DownY AS INTEGER DIM PLMouse AS INTEGER, PRMouse AS INTEGER DIM PUMouse AS INTEGER, PDMouse AS INTEGER DIM PULMouse AS INTEGER, PUULMouse AS INTEGER DIM PURMouse AS INTEGER, PUURMouse AS INTEGER DIM PDLMouse AS INTEGER, PDDLMouse AS INTEGER DIM PDRMouse AS INTEGER, PDDRMouse AS INTEGER DIM TitleMouse AS INTEGER, FormX AS INTEGER, FormY AS INTEGER DIM FilePopup AS QPopupMenu DIM FileButton AS QCoolBtn DIM NewItem AS QMenuItem, OpenItem AS QMenuItem DIM Break1 AS QMenuItem, ExitItem AS QMenuItem DIM RichEdit AS QRichEdit SUB ResizeMainForm IF MainForm.ClientWidth < 22 THEN MainForm.ClientWidth = 22 END IF IF MainForm.ClientHeight < 22 THEN MainForm.ClientHeight = 22 END IF PanelR.Left = MainForm.ClientWidth-3 PanelR.Height = MainForm.ClientHeight - 40 PanelL.Height = MainForm.ClientHeight - 40 PanelU.Width = MainForm.ClientWidth - 40 PanelD.Top = MainForm.ClientHeight-3 PanelD.Width = MainForm.ClientWidth - 40 PanelDL.Top = MainForm.ClientHeight-20 PanelDDL.Top = MainForm.ClientHeight-3 PanelDR.Left = MainForm.ClientWidth-3 PanelDR.Top = MainForm.ClientHeight-20 PanelDDR.Left = MainForm.ClientWidth-20 PanelDDR.Top = MainForm.ClientHeight-3 PanelUR.Left = MainForm.ClientWidth-3 PanelUUR.Left = MainForm.ClientWidth-20 HelpButton.Left = MainForm.ClientWidth - 20 TitlePanel.Width = MainForm.ClientWidth - 75 MainPanel.Width = MainForm.ClientWidth - 6 MainPanel.Height = 30'MainForm.ClientHeight - 23 ' Image.Width = MainForm.ClientWidth - 6 ' Image.Height = MainForm.ClientHeight - 50 RichEdit.Width = MainForm.ClientWidth - 8 RichEdit.Height = MainForm.ClientHeight - 55 END SUB SUB PLMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PLMouse = TRUE DownX = X DownY = Y END SUB SUB PLMouseMove (X AS INTEGER, Y AS INTEGER) IF PLMouse THEN IF MainForm.ClientWidth > 22 THEN MainForm.Left = MainForm.Left+(X - DownX) END IF MainForm.Width = MainForm.Width+(DownX - X) ResizeMainForm END IF END SUB SUB PLMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PLMouse = FALSE END SUB SUB PRMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PRMouse = TRUE DownX = X DownY = Y END SUB SUB PRMouseMove (X AS INTEGER, Y AS INTEGER) IF PRMouse THEN MainForm.Width = MainForm.Width+(X - DownX) ResizeMainForm END IF END SUB SUB PRMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PRMouse = FALSE END SUB SUB PUMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUMouse = TRUE DownX = X DownY = Y END SUB SUB PUMouseMove (X AS INTEGER, Y AS INTEGER) IF PUMouse THEN IF MainForm.ClientHeight > 22 THEN MainForm.Top = MainForm.Top+(Y - DownY) END IF MainForm.Height = MainForm.Height+(DownY - Y) ResizeMainForm END IF END SUB SUB PUMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUMouse = FALSE END SUB SUB PDMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDMouse = TRUE DownX = X DownY = Y END SUB SUB PDMouseMove (X AS INTEGER, Y AS INTEGER) IF PDMouse THEN MainForm.Height = MainForm.Height+(Y - DownY) ResizeMainForm END IF END SUB SUB PDMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDMouse = FALSE END SUB SUB PULMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PULMouse = TRUE DownX = X DownY = Y END SUB SUB PULMouseMove (X AS INTEGER, Y AS INTEGER) IF PULMouse THEN MainForm.Top = MainForm.Top+(Y - DownY) MainForm.Height = MainForm.Height+(DownY - Y) MainForm.Left = MainForm.Left+(X - DownX) MainForm.Width = MainForm.Width+(DownX - X) ResizeMainForm END IF END SUB SUB PULMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PULMouse = FALSE END SUB SUB PUULMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUULMouse = TRUE DownX = X DownY = Y END SUB SUB PUULMouseMove (X AS INTEGER, Y AS INTEGER) IF PUULMouse THEN MainForm.Top = MainForm.Top+(Y - DownY) MainForm.Height = MainForm.Height+(DownY - Y) MainForm.Left = MainForm.Left+(X - DownX) MainForm.Width = MainForm.Width+(DownX - X) ResizeMainForm END IF END SUB SUB PUULMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUULMouse = FALSE END SUB SUB PURMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PURMouse = TRUE DownX = X DownY = Y END SUB SUB PURMouseMove (X AS INTEGER, Y AS INTEGER) IF PURMouse THEN MainForm.Top = MainForm.Top+(Y - DownY) MainForm.Height = MainForm.Height+(DownY - Y) MainForm.Width = MainForm.Width+(X - DownX) ResizeMainForm END IF END SUB SUB PURMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PURMouse = FALSE END SUB SUB PUURMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUURMouse = TRUE DownX = X DownY = Y END SUB SUB PUURMouseMove (X AS INTEGER, Y AS INTEGER) IF PUURMouse THEN MainForm.Top = MainForm.Top+(Y - DownY) MainForm.Height = MainForm.Height+(DownY - Y) MainForm.Width = MainForm.Width+(X - DownX) ResizeMainForm END IF END SUB SUB PUURMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PUURMouse = FALSE END SUB SUB PDLMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDLMouse = TRUE DownX = X DownY = Y END SUB SUB PDLMouseMove (X AS INTEGER, Y AS INTEGER) IF PDLMouse THEN MainForm.Left = MainForm.Left+(X - DownX) MainForm.Width = MainForm.Width+(DownX - X) MainForm.Height = MainForm.Height+(Y - DownY) ResizeMainForm END IF END SUB SUB PDLMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDLMouse = FALSE END SUB SUB PDDLMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDDLMouse = TRUE DownX = X DownY = Y END SUB SUB PDDLMouseMove (X AS INTEGER, Y AS INTEGER) IF PDDLMouse THEN MainForm.Left = MainForm.Left+(X - DownX) MainForm.Width = MainForm.Width+(DownX - X) MainForm.Height = MainForm.Height+(Y - DownY) ResizeMainForm END IF END SUB SUB PDDLMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDDLMouse = FALSE END SUB SUB PDRMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDRMouse = TRUE DownX = X DownY = Y END SUB SUB PDRMouseMove (X AS INTEGER, Y AS INTEGER) IF PDRMouse THEN MainForm.Height = MainForm.Height+(Y - DownY) MainForm.Width = MainForm.Width+(X - DownX) ResizeMainForm END IF END SUB SUB PDRMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDRMouse = FALSE END SUB SUB PDDRMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDDRMouse = TRUE DownX = X DownY = Y END SUB SUB PDDRMouseMove (X AS INTEGER, Y AS INTEGER) IF PDDRMouse THEN MainForm.Height = MainForm.Height+(Y - DownY) MainForm.Width = MainForm.Width+(X - DownX) ResizeMainForm END IF END SUB SUB PDDRMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) PDDRMouse = FALSE END SUB SUB TitleMouseDown (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) TitleMouse = TRUE DownX = X DownY = Y FormX = MainForm.Left FormY = MainForm.Top END SUB SUB TitleMouseMove (X AS INTEGER, Y AS INTEGER) IF TitleMouse = TRUE AND MainForm.WindowState = wsNormal THEN MainForm.Left = FormX + (X - DownX) MainForm.Top = FormY + (Y - DownY) FormX = MainForm.Left FormY = MainForm.Top END IF END SUB SUB TitleMouseUp (BTN AS INTEGER, X AS INTEGER, Y AS INTEGER) TitleMouse = FALSE END SUB SUB MinButtonClick MainForm.WindowState = wsMinimized END SUB SUB MaxButtonClick IF MaxButton.Down = False THEN MainForm.WindowState = wsNormal ResizeMainForm ELSE MainForm.WindowState = wsMaximized ResizeMainForm END IF END SUB SUB HelpButtonClick ShowMessage "Beware the power of Rapid-Q" END SUB SUB FileClick FilePopup.Popup(MainForm.Left + 30, MainForm.Top + 50) END SUB SUB NewClick RichEdit.Clear END SUB SUB OpenClick DIM OpenDialog AS QOpenDialog IF OpenDialog.Execute THEN RichEdit.LoadFromFile(OpenDialog.FileName) END IF END SUB SUB ExitClick MainForm.Close END SUB MainForm.BorderStyle = bsNone MainForm.Center 'MainForm.OnResize = ResizeMainForm PanelR.Parent = MainForm PanelR.Top = 20 PanelR.Width = 3 PanelR.OnMouseDown = PRMouseDown PanelR.OnMouseMove = PRMouseMove PanelR.OnMouseUp = PRMouseUp PanelR.Cursor = crSizeWE PanelL.Parent = MainForm PanelL.Left = 0 PanelL.Top = 20 PanelL.Width = 3 PanelL.OnMouseDown = PLMouseDown PanelL.OnMouseMove = PLMouseMove PanelL.OnMouseUp = PLMouseUp PanelL.Cursor = crSizeWE PanelU.Parent = MainForm PanelU.Left = 20 PanelU.Top = 0 PanelU.Height = 3 PanelU.OnMouseDown = PUMouseDown PanelU.OnMouseMove = PUMouseMove PanelU.OnMouseUp = PUMouseUp PanelU.Cursor = crSizeNS PanelD.Parent = MainForm PanelD.Left = 20 PanelD.Height = 3 PanelD.OnMouseDown = PDMouseDown PanelD.OnMouseMove = PDMouseMove PanelD.OnMouseUp = PDMouseUp PanelD.Cursor = crSizeNS PanelUL.Parent = MainForm PanelUL.Left = 0 PanelUL.Top = 0 PanelUL.Width = 3 PanelUL.Height = 20 PanelUL.OnMouseDown = PULMouseDown PanelUL.OnMouseMove = PULMouseMove PanelUL.OnMouseUp = PULMouseUp PanelUL.Cursor = crSizeNWSE PanelUUL.Parent = MainForm PanelUUL.Left = 0 PanelUUL.Top = 0 PanelUUL.Width = 20 PanelUUL.Height = 3 PanelUUL.OnMouseDown = PUULMouseDown PanelUUL.OnMouseMove = PUULMouseMove PanelUUL.OnMouseUp = PUULMouseUp PanelUUL.Cursor = crSizeNWSE PanelUR.Parent = MainForm PanelUR.Top = 0 PanelUR.Width = 3 PanelUR.Height = 20 PanelUR.OnMouseDown = PURMouseDown PanelUR.OnMouseMove = PURMouseMove PanelUR.OnMouseUp = PURMouseUp PanelUR.Cursor = crSizeNESW PanelUUR.Parent = MainForm PanelUUR.Top = 0 PanelUUR.Width = 20 PanelUUR.Height = 3 PanelUUR.OnMouseDown = PUURMouseDown PanelUUR.OnMouseMove = PUURMouseMove PanelUUR.OnMouseUp = PUURMouseUp PanelUUR.Cursor = crSizeNESW PanelDL.Parent = MainForm PanelDL.Left = 0 PanelDL.Width = 3 PanelDL.Height = 20 PanelDL.OnMouseDown = PDLMouseDown PanelDL.OnMouseMove = PDLMouseMove PanelDL.OnMouseUp = PDLMouseUp PanelDL.Cursor = crSizeNESW PanelDDL.Parent = MainForm PanelDDL.Left = 0 PanelDDL.Width = 20 PanelDDL.Height = 3 PanelDDL.OnMouseDown = PDDLMouseDown PanelDDL.OnMouseMove = PDDLMouseMove PanelDDL.OnMouseUp = PDDLMouseUp PanelDDL.Cursor = crSizeNESW PanelDR.Parent = MainForm PanelDR.Width = 3 PanelDR.Height = 20 PanelDR.OnMouseDown = PDRMouseDown PanelDR.OnMouseMove = PDRMouseMove PanelDR.OnMouseUp = PDRMouseUp PanelDR.Cursor = crSizeNWSE PanelDDR.Parent = MainForm PanelDDR.Width = 20 PanelDDR.Height = 3 PanelDDR.OnMouseDown = PDDRMouseDown PanelDDR.OnMouseMove = PDDRMouseMove PanelDDR.OnMouseUp = PDDRMouseUp PanelDDR.Cursor = crSizeNWSE TitlePanel.Parent = MainForm TitlePanel.Alignment = taLeftJustify TitlePanel.Left = 54 TitlePanel.Top = 3 TitlePanel.Height = 17 TitlePanel.Color = &HDD7777 TitlePanel.Font = Font TitlePanel.Caption = " Custom Forms in Rapid-Q" TitlePanel.OnMouseDown = TitleMouseDown TitlePanel.OnMouseMove = TitleMouseMove TitlePanel.OnMouseUp = TitleMouseUp CloseButton.Parent = MainForm CloseButton.Top = 3 CloseButton.Width = 17 CloseButton.Height = 17 CloseButton.Left = 3 CloseButton.BMPHandle = BMP_Close CloseButton.ModalResult = mrCANCEL MinButton.Parent = MainForm MinButton.Top = 3 MinButton.Width = 17 MinButton.Height = 17 MinButton.Left = 20 MinButton.BMPHandle = BMP_Min MinButton.OnClick = MinButtonClick MaxButton.Parent = MainForm MaxButton.Top = 3 MaxButton.Width = 17 MaxButton.Height = 17 MaxButton.Left = 37 MaxButton.GroupIndex = 1 MaxButton.Down = False MaxButton.AllowAllUp = True MaxButton.BMPHandle = BMP_Max MaxButton.OnClick = MaxButtonClick HelpButton.Parent = MainForm HelpButton.Top = 3 HelpButton.Width = 17 HelpButton.Height = 17 HelpButton.BMPHandle = BMP_Help HelpButton.OnClick = HelpButtonClick MainPanel.Parent = MainForm MainPanel.Left = 3 MainPanel.Top = 21 'Image.Parent = MainForm 'Image.BMPHandle = BMP_IMAGE 'Image.Top = 50 'Image.Left = 3 RichEdit.Parent = MainForm RichEdit.Top = 51 RichEdit.Left = 3 RichEdit.PlainText = True RichEdit.ScrollBars = ssBoth RichEdit.WordWrap = False FileButton.Parent = MainPanel FileButton.Caption = "&File" FileButton.Left = 5 FileButton.Top = 5 FileButton.Width = 50 FileButton.Height = 20 FileButton.Flat = True FIleButton.OnClick = FileClick NewItem.Caption = "&New" NewItem.OnClick = NewClick OpenItem.Caption = "&Open" OpenItem.OnClick = OpenClick Break1.Caption = "-" ExitItem.Caption = "E&xit" ExitItem.OnClick = ExitClick FilePopup.AddItems NewItem, OpenItem, Break1, ExitItem ResizeMainForm MainForm.Caption = "Custom form" MainForm.ShowModal