1
2 #include <windows.h>
3 #include <string.h>
4 #include "commdlg.h"
5 //#include "ctrl.h"
6 #include "lib.h"
7
8 #define MAXLEN_TEMPSTR 81
9
Lib_FindStringInTable(HINSTANCE hInstance,char * lookFor,int startId,WORD wTableLen)10 int NEAR Lib_FindStringInTable(HINSTANCE hInstance, char* lookFor, int startId, WORD wTableLen)
11 {
12 char szBuffer[MAXLEN_TEMPSTR];
13 WORD wCount;
14
15 for (wCount = 0; wCount < wTableLen; wCount++)
16 {
17 LoadString(hInstance, startId + wCount, szBuffer, sizeof(szBuffer));
18 if (!strcmp(szBuffer, lookFor))
19 return (wCount);
20 }
21 return (-1); //not found
22 } // end of Lib_FindStringInTable()
23
Font_SetupInfo(FontInfo_t * pFont)24 int NEAR Font_SetupInfo(FontInfo_t* pFont)
25 {
26 // setup default font information
27 pFont->hFont = 0;
28 pFont->rgbFGColor = RGB(0, 0, 0);
29 pFont->logFont.lfHeight = 12;
30 pFont->logFont.lfWidth = 0;
31 pFont->logFont.lfEscapement = 0;
32 pFont->logFont.lfOrientation = 0;
33 pFont->logFont.lfWeight = 0;
34 pFont->logFont.lfItalic = 0;
35 pFont->logFont.lfUnderline = 0;
36 pFont->logFont.lfStrikeOut = 0;
37 pFont->logFont.lfCharSet = OEM_CHARSET;
38 pFont->logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
39 pFont->logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
40 pFont->logFont.lfQuality = DEFAULT_QUALITY;
41 pFont->logFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
42 lstrcpy(pFont->logFont.lfFaceName, "FixedSys");
43 return (0);
44 }
45
Font_DestroyInfo(FontInfo_t * pFont)46 void NEAR Font_DestroyInfo(FontInfo_t* pFont)
47 {
48 DeleteObject(pFont->hFont);
49 }
50
51 //---------------------------------------------------------------------------
52 // VOID NEAR Lib_FillComboBox(HINSTANCE hInstance, HWND hCtrlWnd, int nIDString,
53 // WORD NEAR *npTable, WORD wTableLen,
54 // WORD wCurrentSetting)
55 //
56 // Description:
57 // Fills the given combo box with strings from the resource
58 // table starting at nIDString. Associated items are
59 // added from given table. The combo box is notified of
60 // the current setting.
61 //
62 // Parameters:
63 // HINSTANCE hInstance
64 // handle to application instance
65 //
66 // HWND hCtrlWnd
67 // handle to combo box control
68 //
69 // int nIDString
70 // first resource string id
71 //
72 // WORD NEAR *npTable
73 // near point to table of associated values
74 //
75 // WORD wTableLen
76 // length of table
77 //
78 // WORD wCurrentSetting
79 // current setting (for combo box selection)
80 //
81 //---------------------------------------------------------------------------
82
Lib_FillComboBox(HINSTANCE hInstance,HWND hCtrlWnd,int nIDString,DWORD NEAR * npTable,WORD wTableLen,DWORD wCurrentSetting)83 void NEAR Lib_FillComboBox(HINSTANCE hInstance, HWND hCtrlWnd, int nIDString, DWORD NEAR *npTable, WORD wTableLen, DWORD wCurrentSetting)
84 {
85 char szBuffer[MAXLEN_TEMPSTR];
86 WORD wCount, wPosition;
87
88 for (wCount = 0; wCount < wTableLen; wCount++)
89 {
90 // load the string from the string resources and
91 // add it to the combo box
92 LoadString(hInstance, nIDString + wCount, szBuffer, sizeof(szBuffer));
93 wPosition = LOWORD(SendMessage(hCtrlWnd, CB_ADDSTRING, 0, (LPARAM) (LPSTR) szBuffer));
94
95 // use item data to store the actual table value
96 SendMessage(hCtrlWnd, CB_SETITEMDATA, (WPARAM) wPosition, (LPARAM) (LONG) *(npTable + wCount));
97
98 // if this is our current setting, select it
99 if (*(npTable + wCount) == wCurrentSetting)
100 SendMessage(hCtrlWnd, CB_SETCURSEL, (WPARAM) wPosition, 0);
101 }
102
103 } // end of Lib_FillComboBox()
104
105 //---------------------------------------------------------------------------
106 // VOID NEAR Lib_ModalDialogBoxParam( HINSTANCE hInstance,
107 // LPCSTR lpszTemplate, HWND hWnd,
108 // DLGPROC lpDlgProc, LPARAM lParam )
109 //
110 // Description:
111 // It is a simple utility function that simply performs the
112 // MPI and invokes the dialog box with a DWORD paramter.
113 //
114 // Parameters:
115 // similar to that of DialogBoxParam() with the exception
116 // that the lpDlgProc is not a procedure instance
117 //
118 //---------------------------------------------------------------------------
119
Lib_ModalDialogBoxParam(HINSTANCE hInstance,LPCSTR lpszTemplate,HWND hWnd,DLGPROC lpDlgProc,LPARAM lParam)120 int NEAR Lib_ModalDialogBoxParam(HINSTANCE hInstance, LPCSTR lpszTemplate, HWND hWnd, DLGPROC lpDlgProc, LPARAM lParam)
121 {
122 DLGPROC lpProcInstance;
123 int ret;
124
125 lpProcInstance = (DLGPROC)MakeProcInstance((FARPROC)lpDlgProc, hInstance);
126 ret = DialogBoxParam(hInstance, lpszTemplate, hWnd, lpProcInstance, lParam);
127 FreeProcInstance((FARPROC)lpProcInstance);
128 return (ret);
129 } // end of Lib_ModalDialogBoxParam()
130
Lib_SelectWorkingFont(HWND hWnd,FontInfo_t NEAR * pFont)131 int NEAR Lib_SelectWorkingFont(HWND hWnd, FontInfo_t NEAR* pFont)
132 {
133 CHOOSEFONT cfTTYFont ;
134
135 cfTTYFont.lStructSize = sizeof(CHOOSEFONT);
136 cfTTYFont.hwndOwner = hWnd;
137 cfTTYFont.hDC = 0;
138 cfTTYFont.rgbColors = pFont->rgbFGColor;
139 cfTTYFont.lpLogFont = &pFont->logFont;
140 cfTTYFont.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_EFFECTS | CF_INITTOLOGFONTSTRUCT;
141 cfTTYFont.lCustData = 0;
142 cfTTYFont.lpfnHook = 0;
143 cfTTYFont.lpTemplateName = 0;
144 cfTTYFont.hInstance = GETHINST(hWnd);
145
146 if (ChooseFont(&cfTTYFont))
147 {
148 pFont->rgbFGColor = cfTTYFont.rgbColors ;
149 return (TRUE);
150 // ResetTTYScreen( GetParent( hWnd ), pXtra) ;
151 }
152 return (FALSE);
153 } // end of Lib_SelectWorkingFont()
154
155