Const Version= "190105" '----- Compiler Directives $OPTIMIZE ON $TYPECHECK ON $ESCAPECHARS ON '----- Code modules $INCLUDE "RapidQ.inc" '----- Win API Function Declarations DECLARE FUNCTION SetWindow LIB "user32" ALIAS "SetWindowLongA"_ (hwnd AS LONG, nIndex AS LONG, dwNewLong AS LONG) AS LONG '----- SUBs Sub SetMin (Form as QForm) 'Allow RQ App to Minimize to Taskbar Setwindow(Form.Handle, -8, 0) Setwindow(Application.Handle, -8, Form.Handle) End Sub '----- Constants $IFNDEF TRUE $DEFINE TRUE 1 $ENDIF $IFNDEF FALSE $DEFINE FALSE 0 $ENDIF '-- ATTENTION -- - Change Path for your system--- $INCLUDE "D:\RapidQ\_BT_Edfinfo\inc\My_QGridEx_190105.inc" '----- Form Event SUB Declarations Declare Sub btnOnClick (SENDER As QBUTTON) Declare Sub mnuEditClick (Sender AS QMenuItem) Declare Sub mnuFileClick (Sender AS QMenuItem) Declare Sub frmMainResize (SENDER As QFORM) Declare Sub frmMainClose Declare Sub CheckSync Declare Sub btCalculClick (SENDER As QBUTTON) Dim i as integer Dim j as integer Dim k as integer Dim SyncModes As QTimer SyncModes.Interval =100 SyncModes.OnTimer = CheckSync '----- Define the main form Create frmMain As QFORM Center Width = 1000 Height = 500 Top = 150 Left = 200 Caption = "Progr.Raduiateurs Fils Pilotes" OnResize = frmMainResize OnClose = frmMainClose Create btCalcul As QBUTTON Caption = "Calculs" Width = 100 Top = 100 Left=1 OnClick = btCalculClick End Create Create btnEdit As QBUTTON Caption = "Enter Row 0" Width = 100 Top = 0 Left=1 OnClick = btnOnClick End Create Create btnSelect As QBUTTON Caption = "Enter SelMode" Width = 100 Top = 25 Left=1 OnClick = btnOnClick End Create Create Grid As QGridEx Align = 4 Width = frmMain.ClientWidth - btnEdit.Width Height = frmMain.ClientHeight End Create Create StatusBar AS QStatusBar SizeGrip = False SimplePanel = True End Create End Create'frmMain CREATE mnuMain as QMAINMENU Parent = frmMain '----- File Menu CREATE mnuFile as QMENUITEM Caption = "&File" Checked = 0 Enabled = 1 Visible = 1 CREATE mnuFileNew as QMENUITEM Caption = "&New" Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE CREATE mnuFileOpen as QMENUITEM Caption = "&Open..." Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE CREATE mnuFileSep1 as QMENUITEM Caption = "-" Checked = 0 Enabled = 0 Visible = 1 END CREATE CREATE mnuFileSave as QMENUITEM Caption = "&Save..." Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE CREATE mnuFileSaveAs as QMENUITEM Caption = "Save &As..." Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE CREATE mnuFileSep2 as QMENUITEM Caption = "-" Checked = 0 Enabled = 0 Visible = 1 END CREATE CREATE mnuFilePrint as QMENUITEM Caption = "&Print..." Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE CREATE mnuFileSep3 as QMENUITEM Caption = "-" Checked = 0 Enabled = 0 Visible = 1 END CREATE CREATE mnuFileExit as QMENUITEM Caption = "E&xit" Checked = 0 Enabled = 1 Visible = 1 OnClick = mnuFileClick END CREATE END CREATE '----- Edit Menu CREATE mnuEdit as QMENUITEM Caption = "&Edit" Enabled = 1 Visible = 1 CREATE mnuEditCut as QMENUITEM Caption = "C&ut" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+x" END CREATE CREATE mnuEditCopy as QMENUITEM Caption = "&Copy" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+c" END CREATE CREATE mnuEditPaste as QMENUITEM Caption = "&Paste" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+v" END CREATE CREATE mnuEditDelete as QMENUITEM Caption = "&Delete" Enabled = 0 Visible = 1 OnClick = mnuEditClick END CREATE CREATE mnuEditSep0 as QMENUITEM Caption = "-" Enabled = 0 Visible = 1 END CREATE CREATE mnuEditSelAll as QMENUITEM Caption = "&Select All" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+a" END CREATE CREATE mnuEditSep1 as QMENUITEM Caption = "-" Enabled = 0 Visible = 1 END CREATE CREATE mnuEditFillDown as QMENUITEM Caption = "&Fill Down" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+d" END CREATE CREATE mnuEditFillRight as QMENUITEM Caption = "Fill &Right" Enabled = 0 Visible = 1 OnClick = mnuEditClick Shortcut = "Ctrl+r" END CREATE CREATE mnuEditFillSeries as QMENUITEM Caption = "Fill S&eries..." Enabled = 0 Visible = 1 OnClick = mnuEditClick END CREATE CREATE mnuEditSort as QMENUITEM Caption = "S&ort..." Enabled = 1 Visible = 1 OnClick = mnuEditClick END CREATE CREATE mnuEditSep2 as QMENUITEM Caption = "-" Enabled = 0 Visible = 1 END CREATE CREATE mnuEditSelMode as QMENUITEM Caption = "Select &Mode" Enabled = 1 Visible = 1 OnClick = mnuEditClick Shortcut = "F2" END CREATE CREATE mnuEditRow0 as QMENUITEM Caption = "Edit Col&umn Labels" Enabled = 1 Visible = 1 OnClick = mnuEditClick Shortcut = "F5" END CREATE END CREATE END CREATE WITH Grid 'Label columns w/letters .Cell(0,1) = "Cumulus" .Cell(0,2) = "Salon " .Cell(0,3) = "SDB " .Cell(0,4) = "CH3-CH2" .Cell(0,5) = "CH1 " .Cell(0,6) = "Codage " END with SetMin(frmMain) 'Allow Minimize to taskbar (in Common.Inc) frmMain.Showmodal Grid.Initialize '------------------------------------------------------------------------------------------- Sub btnOnClick (SENDER As QBUTTON) Dim i As Integer 'Loop counters... Dim j As Integer Select Case Sender.Caption 'Use Caption for "toggle trick" Case "Enter Row 0" 'Careful!, using the popup Grid.ToggleEditTopRow 'can screw this up btnEdit.Caption = "Exit Row 0" 'toggle the Case "Exit Row 0" Grid.ToggleEditTopRow btnEdit.Caption = "Enter Row 0" 'captions! Case "Enter SelMode" Grid.ToggleSelMode btnSelect.Caption = "Exit SelMode" 'toggle the Case "Exit SelMode" Grid.ToggleSelMode btnSelect.Caption = "Enter SelMode" 'captions! End Select StatusBar.SimpleText = " Min Row with Data = " + str$(Grid.MinDataRow) + _ " Max Row with Data = " + str$(Grid.MaxDataRow) + _ " Min Col with Data = " + str$(Grid.MinDataCol) + _ " Max Col with Data = " + str$(Grid.MaxDataCol) End Sub '-------------------------------- File Menu --------------------------------------------------- SUB mnuFileClick (Sender AS QMenuItem) SELECT CASE Sender.Handle Case mnuFileNew.Handle If Grid.SelMode = True Then 'In Select mode btnOnClick(btnSelect) 'Turn it off End If If Grid.EditColLabels = True Then 'Edit Top Row is Active btnOnClick(btnEdit) 'Turn it off End If Grid.Initialize Case mnuFileOpen.Handle If Grid.SelMode = True Then 'In Select mode btnOnClick(btnSelect) 'Turn it off End If If Grid.EditColLabels = True Then 'Edit Top Row is Active btnOnClick(btnEdit) 'Turn it off End If Grid.Initialize Grid.LoadData Grid.Col = 1 : Grid.Row = 1 Case mnuFileSave.Handle Grid.SaveData (False) frmMain.Caption = "WinStatZ " + "[" + Grid.CurrFile + "]" Case mnuFileSaveAs.Handle Grid.SaveData (True) frmMain.Caption = "WinStatZ " + "[" + Grid.CurrFile + "]" Case mnuFilePrint.Handle Grid.PrintGrid(PRINTER.PrinterIndex, poPortrait, 1, True) Case mnuFileExit.Handle frmMainClose END SELECT END SUB '----------------------------- Edit Menu ------------------------------------------------------ SUB mnuEditClick (Sender AS QMenuItem) SELECT CASE Sender.Handle Case mnuEditCut.Handle If Grid.SelRange.lCol = 0 Then ShowMessage("Select a Range of Cells First") Else Grid.rngCut End If Case mnuEditCopy.Handle If Grid.SelRange.lCol = 0 Then ShowMessage("Select a Range of Cells First") Else Grid.rngCopy End If Case mnuEditPaste.Handle If Grid.SelExists = 0 Then ShowMessage(" No Data on Clipboard\n\nCut or Copy a Selection First") Else Grid.rngPaste End If Case mnuEditDelete.Handle If Grid.SelRange.lCol = 0 Then ShowMessage("Select a Range of Cells First") Else Grid.rngDelete End If Case mnuEditSelAll.Handle Grid.rngSelAll Case mnuEditFillDown.Handle Grid.rngFillDown Case mnuEditFillRight.Handle Grid.rngFillRight Case mnuEditFillSeries.Handle Grid.rngFillSeries Case mnuEditSort.Handle Grid.Sort Case mnuEditSelMode.Handle btnOnClick(btnSelect) Case mnuEditRow0.Handle btnOnClick(btnEdit) END SELECT END SUB '------------------------------------------------------------------------------------------- Sub frmMainResize (SENDER As QFORM) '----- Prevent initial resize exception If frmMain.Visible = False Then Exit Sub 'Plus anything else that needs doing in your form resize Grid.Width = frmMain.ClientWidth- btnEdit.Width Grid.Height = frmMain.ClientHeight End Sub '---------------------------------------------------------------------------------------------- SUB CheckSync mnuEditSelMode.Checked = Grid.SelMode mnuEditCut.Enabled = Grid.SelMode mnuEditCopy.Enabled = Grid.SelMode mnuEditPaste.Enabled = Grid.SelExists mnuEditDelete.Enabled = Grid.SelMode mnuEditSelAll.Enabled = Grid.SelMode mnuEditFillDown.Enabled = Grid.SelRange.bRow > Grid.SelRange.tRow mnuEditFillRight.Enabled = Grid.SelRange.rCol > Grid.SelRange.lCol mnuEditFillSeries.Enabled = Grid.SelMode If mnuEditSelMode.Checked = True Then 'Out of Sync btnSelect.Caption = "Exit SelMode" End If If mnuEditSelMode.Checked = False Then 'Out of Sync btnSelect.Caption = "Enter SelMode" End If mnuEditRow0.Checked = Grid.EditColLabels If mnuEditRow0.Checked = True Then 'Out of Sync btnEdit.Caption = "Exit Row 0" End If If mnuEditRow0.Checked = False Then 'Out of Sync btnEdit.Caption = "Enter Row 0" End If End Sub '---------------------------------------------------------------------------------------------- Sub frmMainClose Application.Terminate End Sub '------------------------------------------------------------------------------------------- Sub btCalculClick (SENDER As QBUTTON) Dim i As Integer 'Loop counters... Dim j As Integer Dim k As Integer dim P as integer dim a$ dim V as variant WITH Grid 'Label columns w/letters .Cell(0,1) = "Cumulus" .Cell(0,2) = "Salon " .Cell(0,3) = "SDB " .Cell(0,4) = "CH3-CH2" .Cell(0,5) = "CH1 " .Cell(0,6) = "Codage " END with Messagebox ("Lecture programmation Horaire "+ chr$(13),"calcul consigne radiateurs",0 ) k=0 FOR j=1 TO 24 k=0 FOR i=0 TO 4 V=Grid.Cell(j,5-i) p=i*2 select case V case "H" K=K + 2 SHL P case "E" k=K+ 3 shl P case "C" ' rien case "A" k=K+ 1 shl P case "M" K=k+256 case "S" ' rien 'K=K and &h00FF end select NEXT i v=str$(k) Grid.Cell(j,6)=v Next J end sub