|
Callback |
Top Previous Next |
|
Just a couple of points about how MLG might work best with the parent Callback function (written in Powerbasic but meaning should be apparent for other languages). 1) In the %WM_PAINT message handler, explicitly redraw the MLG custom code otherwise a redraw of MLG (and other custom controls) may not be reliable. 2) If it is desired to have your dialog resizable, code must be put in the %WM_SIZE message handler to achieved the desired results.
Powerbasic DDT Style CALLBACK FUNCTION ShowOneGridProc() LOCAL I AS LONG LOCAL J AS LONG LOCAL K AS LONG LOCAL myrow AS LONG LOCAL mycol AS LONG LOCAL MLGN AS MyGridData PTR
SELECT CASE CBMSG CASE %WM_PAINT CONTROL REDRAW CBHNDL, %IDC_MLGGRID3
CASE %WM_SIZE DIALOG GET SIZE CBHNDL TO I, J CONTROL SET SIZE CBHNDL,%IDC_MLGGRID3, I-14, J-56 CONTROL SET SIZE CBHNDL,500, I-14, 30 CONTROL SET LOC CBHNDL,500, 4, J-46
CASE %WM_NOTIFY MLGN=lParam
IF @MLGN.NMHeader.idFrom = %IDC_MLGGRID3 THEN' Notification messages SELECT CASE @MLGN.NMHeader.code
CASE %MLGN_RETURN myrow=@MLGN.Param1 'current row mycol=@MLGN.Param2 'current col . . .
END SELECT END IF END SELECT
END FUNCTION
-------------------------------------------------------------------------------------------------
Windows SDK Style
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _ BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
LOCAL hDC AS DWORD LOCAL pPaint AS PAINTSTRUCT LOCAL tRect AS RECT LOCAL myrow AS LONG LOCAL mycol AS LONG LOCAL myitem AS LONG LOCAL a AS ASCIIZ * 255 LOCAL mystr AS STRING LOCAL MLGN AS MyGridData PTR
SELECT CASE wMsg
CASE %WM_CREATE 'Nothing for now CASE %WM_SIZE GetClientRect hWnd, tRect SetWindowPos hGrid, %HWND_TOP, 4 , 4, tRect.nRight-8,tRect.nBottom-8,%SWP_NOZORDER
CASE %WM_PAINT
hDC = BeginPaint(hWnd, pPaint) '... code here EndPaint hWnd, pPaint FUNCTION = 1 EXIT FUNCTION
CASE %WM_DESTROY PostQuitMessage 0 EXIT FUNCTION
CASE %WM_NOTIFY MLGN=lParam
IF @MLGN.NMHeader.idFrom = %IDC_MLGGRID THEN' Notification messages SELECT CASE @MLGN.NMHeader.code
CASE %MLGN_RCLICKMENU myitem=@MLGN.Param3 ' Menu Item mycol=@MLGN.Param2 ' Column of Mouse myrow=@MLGN.Param1 ' Row of Mouse
IF myitem=1 THEN SendMessage hGrid, %MLG_GETCELL ,MAKLNG(myrow,mycol),VARPTR(a) MSGBOX a SetFocus hGrid END IF
END SELECT END IF END SELECT
FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
END FUNCTION
|