Hi to all
I have PUT together a rough example showing a problem when I drag a Dialog Box.
When you run the program and press Start Button you will see a bunch of colored numbers count.
When you Drag the Dialog Box you will notice the numbers stop counting, once released the counting
starts again. I was wondering if there is a way to return back to the application so it can continue
counting when dragged?. To give you some background info on the application, I Read Data from a
High Speed CAN Bus, this data has to be read, processed and sometimes logged. To keep up with this
High Speed traffic I have to talk to a DLL which talks to a device which passes the Data to me.
I originally Read the Data using Threads but it was a touch slow and could not keep up, I then tried
Timer and it worked well but was a touch slow not keeping up with the high flow of data. In the Example Code
shown seems to work the fastest and can keep up with the Data, the only drawback is when
the Window is dragged the program stops reading the Data which can cause the buffer to overflow and
not process the Data. Maybe with Timer or Threads there are tricks to make it work faster but
I am limited with Windows experience.
I have PUT together a rough example showing a problem when I drag a Dialog Box.
When you run the program and press Start Button you will see a bunch of colored numbers count.
When you Drag the Dialog Box you will notice the numbers stop counting, once released the counting
starts again. I was wondering if there is a way to return back to the application so it can continue
counting when dragged?. To give you some background info on the application, I Read Data from a
High Speed CAN Bus, this data has to be read, processed and sometimes logged. To keep up with this
High Speed traffic I have to talk to a DLL which talks to a device which passes the Data to me.
I originally Read the Data using Threads but it was a touch slow and could not keep up, I then tried
Timer and it worked well but was a touch slow not keeping up with the high flow of data. In the Example Code
shown seems to work the fastest and can keep up with the Data, the only drawback is when
the Window is dragged the program stops reading the Data which can cause the buffer to overflow and
not process the Data. Maybe with Timer or Threads there are tricks to make it work faster but
I am limited with Windows experience.
Code:
#PBFORMS CREATED V1.51 '------------------------------------------------------------------------------ ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '------------------------------------------------------------------------------ #COMPILE EXE #DIM ALL '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #PBFORMS BEGIN INCLUDES %USEMACROS = 1 #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #IF NOT %DEF(%COMMCTRL_INC) #INCLUDE "COMMCTRL.INC" #ENDIF #INCLUDE "PBForms.INC" #PBFORMS END INCLUDES '------------------------------------------------------------------------------ ' ** Constants ** '------------------------------------------------------------------------------ #PBFORMS BEGIN CONSTANTS %IDD_DIALOG1 = 101 %IDC_GRAPHIC1 = 102 %IDC_GRAPHIC2 = 103 %IDC_GRAPHIC3 = 104 %IDC_FRAME1 = 138 %IDC_StartComms = 139 %IDC_StopComms = 140 #PBFORMS END CONSTANTS '--------------------------------------------------------------------------- ' ** Declarations ** '------------------------------------------------------------------------------ DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG DECLARE CALLBACK FUNCTION ShowDIALOG2Proc() DECLARE FUNCTION ShowDIALOG2(BYVAL hDlg AS DWORD) AS LONG #PBFORMS DECLARATIONS GLOBAL hFont AS LONG GLOBAL Abort AS LONG GLOBAL C() AS LONG '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES) ShowDIALOG1 %HWND_DESKTOP END FUNCTION '------------------------------------------------------------------------------ ' ** CallBacks ** '------------------------------------------------------------------------------ CALLBACK FUNCTION ShowDIALOG1Proc() DIM C(10) AS GLOBAL LONG SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG FONT NEW "FIXEDSYS", 10 TO hFont C(0) = %BLACK C(1) = %BLUE C(2) = %GREEN C(3) = %CYAN C(4) = %RED C(5) = %MAGENTA C(6) = %YELLOW C(7) = %WHITE C(8) = %GRAY C(9) = %LTGRAY CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_DESTROY Abort = -1 CASE %WM_MOVE CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDC_StartComms IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN Abort = 0 Showpacket (CB.HNDL) END IF CASE %IDC_StopComms IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN Abort = -1 END IF END SELECT END SELECT END FUNCTION '------------------------------------------------------------------------------ ' ** Dialogs ** '------------------------------------------------------------------------------ FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG,w AS LONG, h AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->-> LOCAL hDlg AS DWORD LOCAL hFont1 AS DWORD DIALOG NEW PIXELS, hParent, "Test", 260, 143, 400, 315, %WS_POPUP OR _ %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _ %WS_VISIBLE OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _ %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 30, 41, 322, 24, %WS_CHILD _ OR %WS_VISIBLE OR %WS_BORDER CONTROL ADD BUTTON, hDlg, %IDC_StartComms, "Start", 68, 244, 90, 48, _ %WS_CHILD OR %WS_VISIBLE OR %BS_TEXT OR %BS_PUSHBUTTON OR %BS_CENTER _ OR %BS_VCENTER, %WS_EX_LEFT OR %WS_EX_LTRREADING CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC2, "", 30, 89, 322, 25, %WS_CHILD _ OR %WS_VISIBLE OR %WS_BORDER CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC3, "", 30, 138, 322, 24, %WS_CHILD _ OR %WS_VISIBLE OR %WS_BORDER CONTROL ADD FRAME, hDlg, %IDC_FRAME1, "PID's", 8, 8, 382, 203 CONTROL ADD BUTTON, hDlg, %IDC_StopComms, "Stop", 225, 244, 90, 48 hFont1 = PBFormsMakeFont("MS Sans Serif", 10, 400, %FALSE, %FALSE, _ %FALSE, %ANSI_CHARSET) CONTROL SEND hDlg, %IDC_StartComms, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_FRAME1, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_StopComms, %WM_SETFONT, hFont1, 0 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 DeleteObject hFont1 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '------------------------------------------------------------------------------ SUB PrintBox (BYVAL hDlg AS DWORD, _ BYVAL ID AS LONG, _ BYVAL sText AS STRING, _ BYVAL X AS LONG, _ BYVAL FontClr AS LONG) LOCAL Xpos AS LONG DECR X XPos = X * 8 + 5 GRAPHIC ATTACH hDlg, ID, REDRAW GRAPHIC SET FONT hFont GRAPHIC COLOR FontClr, -1 GRAPHIC SET POS (Xpos, 2) GRAPHIC PRINT sText END SUB '------------------------------------------------------------------------------ FUNCTION ShowPacket (BYVAL CTLHandle AS DWORD) AS LONG LOCAL A AS LONG LOCAL X AS LONG LOCAL Z AS LONG DO PrintBox CTLHandle, %IDC_GRAPHIC1+X, USING$("####";A), 15, C(Z) GRAPHIC REDRAW DIALOG DOEVENTS 50 IF Abort THEN EXIT DO INCR A: IF A > 1000 THEN A = 0 INCR X: IF X > 2 THEN X = 0 INCR Z: IF Z > 9 THEN Z = 0 LOOP END FUNCTION '------------------------------------------------------------------------------
Comment