--- pmsdk/samples/bio/bio.c 2018/08/09 12:28:13 1.1.1.1 +++ pmsdk/samples/bio/bio.c 2018/08/09 12:28:33 1.1.1.2 @@ -1,6 +1,6 @@ /* Biorhythm - Utility to compute personal biorhythm charts. * -* Created by Microsoft Corp., 1988 +* Created by Microsoft Corp., 1989 * * Purpose: * Program entry point, initialization and GetMessage loop. @@ -46,16 +46,23 @@ HWND hwndApp, hwndKid; HWND hwndAppFrame, hwndKidFrame; char szAppName[10]; char szKidName[10]; -ULONG AppCtlData = FCF_STANDARD | FCF_VERTSCROLL; -ULONG KidCtlData = FCF_TITLEBAR | FCF_SYSMENU; +ULONG AppCtlData = FCF_STANDARD | FCF_VERTSCROLL | FCF_NOBYTEALIGN & ~FCF_SHELLPOSITION; +ULONG KidCtlData = FCF_TITLEBAR; +PFNWP OldFrameWndProc; /* Read-only global variables */ extern FONTMETRICS tmFontInfo; +extern SHORT cxLegendField; +extern SHORT cxDateField; SHORT cdecl main( ) { QMSG qMsg; SHORT dx, dy, x, y; + SHORT cxSizeBorder; + SHORT cySizeBorder; + SHORT cxBorder; + SHORT cyBorder; /* Standard initialization. Get anchor block and message queue. */ hAB = WinInitialize(NULL); @@ -63,26 +70,25 @@ SHORT cdecl main( ) /* Get string constants for parent and child window registration and creation from resource string table. */ - WinLoadString( hAB, NULL, IDSAPPNAME, sizeof(szAppName), szAppName ); - WinLoadString( hAB, NULL, IDSKIDNAME, sizeof(szKidName), szKidName ); + WinLoadString( hAB, NULL, IDS_APPNAME, sizeof(szAppName), szAppName ); + WinLoadString( hAB, NULL, IDS_KIDNAME, sizeof(szKidName), szKidName ); /* Register parent window. Terminate if error. */ if ( !WinRegisterClass( hAB, szAppName, BioWndProc, - CS_CLIPCHILDREN | CS_SIZEREDRAW, NULL ) ) + CS_CLIPCHILDREN | CS_SIZEREDRAW, NULL ) ) return( FALSE ); /* Register child window. Terminate if error. */ - if ( !WinRegisterClass( hAB, szKidName, KidWndProc, - CS_SIZEREDRAW, NULL ) ) + if ( !WinRegisterClass( hAB, szKidName, KidWndProc, 0L, NULL ) ) return( FALSE ); /* Create a parent window of class szAppName */ hwndAppFrame = WinCreateStdWindow( HWND_DESKTOP, - FS_ICON | FS_ACCELTABLE, + 0L, &AppCtlData, szAppName, - szAppName, + NULL, 0L, NULL, ID_BIO, @@ -102,27 +108,37 @@ SHORT cdecl main( ) (HWND FAR *)&hwndKid ); - /* Get the size of the screen in pixels. Used to place and size window */ - x = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); - y = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); + /* Subclass frame so that minimum window size can be controled */ + OldFrameWndProc = WinSubclassWindow( hwndAppFrame, FrameWndProc ); + + /* Get the size of the screen and border. Used to place and size window */ + cxSizeBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSIZEBORDER ); + cySizeBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER ); + cxBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXBORDER ); + cyBorder = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ); + x = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); + y = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); /* Calculate width and height of child window. Must be able to - display three lines vertically by 21 characters wide. Must - include Titlebar and border vertical sizes. */ - dx = (SHORT)tmFontInfo.lAveCharWidth * 21; + display three lines and wide enough for text and corresponding colored + line. Must take into account titlebar and border vertical sizes. */ + dx = cxLegendField * 2; dy = (SHORT)(tmFontInfo.lMaxBaselineExt*3 + WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ) + WinQuerySysValue( HWND_DESKTOP, SV_CYBORDER ) * 2); - /* Place and size parent and child windows. Then make 'em visible. + /* Place and size parent and child windows, then make them visible. WinCreateStdWindow does not include position and size arguments. - Parent window is a 256 pixels wide by full screen high. Child - window is placed 10 pixels over and up from the parent window's - lower left corner. */ - WinSetWindowPos( hwndAppFrame, NULL, x-256, 0, 256, y, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE ); - WinSetWindowPos( hwndKidFrame, NULL, 10, 10, dx, dy, SWP_MOVE | SWP_SIZE | SWP_ACTIVATE ); - WinShowWindow( hwndAppFrame, TRUE ); - WinShowWindow( hwndKidFrame, TRUE ); + Parent window is thin, but full screen high. Child window is placed + 10 pixels over and up from the parent window's lower left corner. */ + WinSetWindowPos( hwndAppFrame, NULL, + x-(3*cxDateField)+cxSizeBorder, + -cySizeBorder, + (3*cxDateField), + y+2*cySizeBorder, + SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW ); + WinSetWindowPos( hwndKidFrame, NULL, 10, 10, dx, dy, + SWP_MOVE | SWP_SIZE | SWP_ACTIVATE | SWP_SHOW ); /* Get messages from application queue and dispatch them for processing */ while( WinGetMsg( hAB, &qMsg, (HWND)NULL, 0, 0 ) ) @@ -130,7 +146,7 @@ SHORT cdecl main( ) WinDispatchMsg( hAB, &qMsg ); } - /* Cleanup mess. All child windows will be destoyed automatically */ + /* Clean up. All child windows will be destoyed automatically */ WinDestroyWindow( hwndAppFrame ); WinDestroyMsgQueue( hMsgQ ); WinTerminate( hAB );