source: branches/v2.9/common_functions/ini_funcs.c

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 4.0 KB
Line 
1/*
2 * This file is (C) Chris Wohlgemuth 2001-2004
3 */
4
5#define INCL_WIN
6
7#include <os2.h>
8
9/*
10 hini may be NULL. Then the filename is used to open the ini file.
11 */
12/*!**************************************************/
13/* */
14/* @@DESC */
15/* */
16/* This funktion stores a window position in an INI */
17/* file. */
18/* */
19/* @@REMARKS */
20/* */
21/* If hini is NULL the given file name will be used */
22/* for opening the INI file. If hini is not NULL */
23/* the file name is ignored. */
24/* */
25/* @@RETURNS */
26/* */
27/* BOOL fSuccess */
28/* */
29/* TRUE: Function succeeded. */
30/* FALSE: Error occurred */
31/* */
32/*!!*************************************************/
33BOOL IniSaveWindowPos(HINI hini, char * iniFile, char* chrApp, char *chrKey, HWND hwnd)
34{
35 BOOL bError=FALSE;
36 SWP swp;
37 HINI hiniPriv=hini;
38
39 if(!hini && !iniFile)
40 return FALSE;
41
42 do{
43
44 if(!hiniPriv) {
45 /* Open ini-file */
46 if((hiniPriv=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)iniFile))
47 ==NULLHANDLE)
48 break;
49 }/* end of if(!hiniPriv) */
50
51 WinQueryWindowPos(hwnd, &swp);
52 if(!PrfWriteProfileData(hiniPriv, chrApp, chrKey, &swp, sizeof(swp)))
53 bError=TRUE;
54
55 if(hiniPriv && !hini)
56 PrfCloseProfile(hiniPriv);
57
58 if(bError)
59 break;
60 return TRUE;
61 } while(TRUE);
62 return FALSE;
63}
64
65/*!**************************************************/
66/* */
67/* @@DESC */
68/* */
69/* This funktion gets a saved window position from */
70/* an INI file and resizes and moves the window */
71/* accordingly. */
72/* */
73/* @@REMARKS */
74/* */
75/* If hini is NULL the given file name will be used */
76/* for opening the INI file. If hini is not NULL */
77/* the file name is ignored. */
78/* */
79/* @@RETURNS */
80/* */
81/* BOOL fSuccess */
82/* */
83/* TRUE: Function succeeded. */
84/* FALSE: Error occurred */
85/* */
86/*!!*************************************************/
87BOOL IniRestoreWindowPos(HINI hini, char * iniFile, char* chrApp, char *chrKey, HWND hwnd, ULONG fSize)
88{
89 HINI hiniPriv=hini;
90 ULONG ulSize;
91 BOOL bError=FALSE;
92 SWP swp;
93
94 do{
95 if(!hiniPriv) {
96 if((hiniPriv=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),(unsigned char *)iniFile))
97 ==NULLHANDLE)
98 break;
99 }/* end of if(!hini) */
100
101 ulSize=sizeof(swp);
102 if(!PrfQueryProfileData(hiniPriv, chrApp, chrKey, &swp, &ulSize))
103 bError=TRUE;
104
105 if(hiniPriv && !hini)
106 PrfCloseProfile(hiniPriv);
107
108 if(bError)
109 break;
110 WinSetWindowPos(hwnd, NULLHANDLE, swp.x, swp.y, swp.cx, swp.cy, SWP_MOVE | fSize);
111 return TRUE;
112 } while(TRUE);
113
114 return FALSE;
115}
116
117
118
Note: See TracBrowser for help on using the repository browser.