Program starts unresponsive

I've written a sort of initialization program for another program. This "initialization" program becomes unresponsive immediately after being run. I've looked through many times, but can't quite seem to figure it out.

I'll start off with WinMain and the WM_CREATE sections (though I don't think there are any problems there), and if you need to see more, let me know.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR sArg, int iShow)
{
  WNDCLASSEX clOpen;
  HWND hOpen;
  MSG iMsg;
  clOpen.hInstance=hInstance;
  clOpen.lpszClassName=sOpen;
  clOpen.lpfnWndProc=OpenWinProc;
  clOpen.style=CS_DBLCLKS;
  clOpen.cbSize=sizeof(WNDCLASSEX);
  clOpen.hIcon=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hCursor=LoadCursor(NULL, IDC_ARROW);
  clOpen.lpszMenuName=NULL;
  clOpen.cbClsExtra=0;
  clOpen.cbWndExtra=0;
  clOpen.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
  if(!RegisterClassEx(&clOpen))
  {
    MessageBox(NULL, "Windows Failed To Register Class.", "Fatal Error",
               MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
    return 0;
  }
  else
  {
    RECT clRect={0, 0, 800, 600};
    AdjustWindowRectEx(&clRect, WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, FALSE, WS_EX_CLIENTEDGE);
    hOpen=CreateWindowEx(WS_EX_CLIENTEDGE, sOpen, "Your Virtual Library", WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, CW_USEDEFAULT,
                         CW_USEDEFAULT, clRect.right-clRect.left, clRect.bottom-clRect.top, HWND_DESKTOP, NULL, hInstance, NULL);
    if(hOpen==NULL)
    {
      MessageBox(NULL, "Windows Failed To Create Window.", "Fatal Error",
                 MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
      return 0;
    }
    else
    {
      ShowWindow(hOpen, iShow);
      UpdateWindow(hOpen);
      while(GetMessage(&iMsg, NULL, 0, 0))
      {
        TranslateMessage(&iMsg);
        DispatchMessage(&iMsg);
      }
    }
  }
  return iMsg.wParam;
}

LRESULT CALLBACK OpenWinProc(HWND hOpen, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
  // Some other stuff here
  switch(iMsg)
  {
    case WM_CREATE:
    {
      ShowWindow(hOpen, SW_SHOW);
      // vhWin[0]=CreateWindowEx(0, "Button", "", WS_CHILD|BS_PUSHBUTTON, 0, 0, 1, 1,
      //                         hOpen, (HMENU)IDB_NEXT, GetModuleHandle(NULL), NULL);
      SendMessage(hOpen, WM_COMMAND, MAKEWPARAM(IDB_NEXT, BN_CLICKED), (LPARAM)vhWin[0]);
    }
      break;
    // Other stuff here
  }
  return 0;
}


The call to ShowWindow in WM_CREATE was added after the program was initially created, because without it the window wouldn't show at all (I believe this may have something to do with the problem). The commented out call to the CreateWindowEx function within WM_CREATE was added afterwards, thinking that maybe SendMessage would cause the the program to hang if the handle in the lParam was not yet a valid handle. However, that did not fix the "unresponsive" problem.
Your WinMain seems weird to me, why don't you use a default generated one ? Most IDE have WinMain templates, like Code::Blocks, which is guaranteed to work.

Then start adding your code and see what happens.
Actually, I am using Code::Blocks. The WinMain in the post above is (for the most part) the one from the "Frame Based" option in the "Win 32 GUI" option from File -> New -> Project... I changed the variable names, removed all of the comments/blank lines/unnecessary white spaces, and added in a little bit, but then saved as a custom template. This is the (for the most part) the WinMain used in all of my programs, and I have another working program using the exact same WinMain (only difference between them: using hMain instead of hOpen).

Though, to be fair, you have said that it seems weird to you. I guess it's generally user dependent (different people use different things, and since it's the one I'm used to using, it doesn't seem weird to me).

My point though, I have this same WinMain function in another program that does run, and does not automatically become unresponsive. Therefore, I assume the problem is not there.

EDIT: I have used Search -> Replace from the Code::Block's menu to rename all instances of hOpen with hMain. The WinMain function is now exactly the same as my working program's however this particular one still becomes unresponsive when run.
Last edited on
Okay, using multiple calls to MessageBox() I think I found the part that freezes it. I'll start off by posting a little more code (revised edition, with message boxes):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
LRESULT CALLBACK OpenWinProc(HWND hMain, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
  HWND vhWin[19];/*
    HWND hNext;
    HWND hIntro, hNext1;
    HWND hTerms, hAccept, hDeny, hNext2;
    HWND hAccount, hProtect, hNext3;
    HWND hMemory, hUser, hPass, hNext4;
    HWND hOrganize, hOrg, hFinish;
    HWND hShow, hProgress;*/
  UINT iCount=0;
  BOOL bFin=FALSE;
  switch(iMsg)
  {
    case WM_CREATE:
    {
      MessageBox(NULL, "Showing Window Now", "Information", MB_ICONINFORMATION|MB_OK);
      ShowWindow(hMain, SW_SHOW);
      MessageBox(NULL, "Starting Loop Now", "Information", MB_ICONINFORMATION|MB_OK);
      iCount=0;
      do
      {
        vhWin[iCount]=NULL;
        iCount++;
      }
      while(iCount<sizeof(vhWin));
      MessageBox(NULL, "Sending Message Now", "Information", MB_ICONINFORMATION|MB_OK);
      SendMessage(hMain, WM_COMMAND, MAKEWPARAM(IDB_NEXT, BN_CLICKED), (LPARAM)vhWin[0]);
    }
      break;
    // Other stuff here
  }
  return 0;
}


The program displayed the "Starting Loop Now" message box, then became unresponsive. This loop is meant to initialize the HWND elements of the vhWin array to NULL.

The separate HWND elements that have been commented out were the original ones used while originally writing the program. I decided to switch to the array for:

1
2
3
4
5
6
7
8
9
10
iCount=0;
do
{
  if(vhWin[iCount]!=NULL)
  {
    DestroyWindow(vhWin[iCount]);
    iCount++;
  }
}
while(iCount<sizeof(vhWin));


Which is used at several points throughout the program to (theoretically) destroy all controls that are currently displayed, without knowing at every point which ones are displayed.

Note: I don't know if this is wrong/bad. If the program is becoming unresponsive due to problems with the array, would there be another way to do this? The only other ones I can think of would be to use an external function with a very long if...else if... statement, or a lot of IsWindow() calls. :\
Last edited on
On my system, sizeof (vhWin) return 76, so you know what that means, don't you ?
Your program attempts to write outside of bounds of vxWin array and crashes.

Use something like sizeof (vhWin ) / sizeof (vhWin[0]) or _countof() macro if it is available instead.
Thank you very much modoran, I hadn't realized that was happening. (It honestly never occurred to me to check that, and I didn't realize it was using the array's size rather than the number of units...oddly enough considering it says sizeof) XD

I changed sizeof(vhWin) to sizeof(vhWin)/sizeof(vhWin[0]) as you suggested, because I added <stdlib.h> (as suggested on the msdn page for the _countof() macro. However, when compiling it gave me this error:

error: '_countof' was not declared in this scope


It passed through the WM_CREATE section of the code now, but it got stuck and became unresponsive on the first call to the theoretical window destroying loop from my previous post. Though I changed those as well, so it now looks like this:

1
2
3
4
5
6
7
8
9
10
iCount=0;
do
{
  if(vhWin[iCount]!=NULL)
  {
    DestroyWindow(vhWin[iCount]);
    iCount++;
  }
}
while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));


I also tried changing that to:

1
2
3
4
5
6
7
8
9
10
iCount=0;
do
{
  if(IsWindow(vhWin[iCount]))
  {
    DestroyWindow(vhWin[iCount]);
    iCount++;
  }
}
while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));


However both cause the same unresponsive problem.
Can you post your whole code? I'll try to help
TTT wrote:
Can you post your whole code? I'll try to help

Oh boy...I have a feeling that this is going to be a bit embarrassing...but, here goes...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#include <windows.h>
#include <commctrl.h>
#include <math.h>
#include <objbase.h>
#include <shlobj.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <string>

#define IDB_NEXT 01001
#define IDB_NEXT1 01002
#define IDB_ACCEPT 01003
#define IDB_DENY 01004
#define IDB_NEXT2 01005
#define IDB_PROTECT 01006
#define IDB_NEXT3 01007
#define IDB_USER_MEM 01011
#define IDB_PASS_MEM 01012
#define IDB_NEXT4 01013
#define IDB_FINISH 01014
#define IDC_INT_STATIC 02001
#define IDC_TER_STATIC 02002
#define IDC_USE_STATIC 02003
#define IDC_MEM_STATIC 02004
#define IDC_ORG_STATIC 02005
#define IDC_ORG 02006
#define IDC_PRO_STATIC 02007
#define IDC_BASE_PROGRESS 02010

LRESULT CALLBACK OpenWinProc(HWND, UINT, WPARAM, LPARAM);
std::string GetIntroText();
std::string GetTermsText();
std::string GetAccountText();
std::string GetMemoryText();
std::string GetOrganizeText();

class clInitial
{
  public:
    BOOL bProtect;
    BOOL bUserAcc;
    BOOL bUserMem;
    BOOL bPassMem;
    BOOL bAuthOrg;
    BOOL bTitlOrg;
    BOOL bGenrOrg;
    BOOL bPublOrg;
    BOOL bDateOrg;
}clInit;

class clPath
{
  public:
    std::string sApp;
    std::string sCur;
    std::string sTar;
}clPaths;

const char sOpen[]="OpenWin";
const char sSys[]="SysWin";

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR sArg, int iShow)
{
  HWND hMain;
  MSG iMsg;
  WNDCLASSEX clOpen;
  clOpen.hInstance=hInstance;
  clOpen.lpszClassName=sOpen;
  clOpen.lpfnWndProc=OpenWinProc;
  clOpen.style=CS_DBLCLKS;
  clOpen.cbSize=sizeof(WNDCLASSEX);
  clOpen.hIcon=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hCursor=LoadCursor(NULL, IDC_ARROW);
  clOpen.lpszMenuName=NULL;
  clOpen.cbClsExtra=0;
  clOpen.cbWndExtra=0;
  clOpen.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
  if(!RegisterClassEx(&clOpen))
  {
    MessageBox(NULL, "Windows Failed To Register Class.", "Fatal Error",
               MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
    return 0;
  }
  else
  {
    RECT clRect={0, 0, 800, 600};
    AdjustWindowRectEx(&clRect, WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, FALSE, WS_EX_CLIENTEDGE);
    hMain=CreateWindowEx(WS_EX_CLIENTEDGE, sOpen, "Your Virtual Library", WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, CW_USEDEFAULT,
                         CW_USEDEFAULT, clRect.right-clRect.left, clRect.bottom-clRect.top, HWND_DESKTOP, NULL, hInstance, NULL);
    if(hMain==NULL)
    {
      MessageBox(NULL, "Windows Failed To Create Window.", "Fatal Error",
                 MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
      return 0;
    }
    else
    {
      ShowWindow(hMain, iShow);
      UpdateWindow(hMain);
      while(GetMessage(&iMsg, NULL, 0, 0))
      {
        TranslateMessage(&iMsg);
        DispatchMessage(&iMsg);
      }
    }
  }
  return iMsg.wParam;
}

LRESULT CALLBACK OpenWinProc(HWND hMain, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
  HWND vhWin[19];/*
    HWND hNext;
    HWND hIntro, hNext1;
    HWND hTerms, hAccept, hDeny, hNext2;
    HWND hAccount, hProtect, hNext3;
    HWND hMemory, hUser, hPass, hNext4;
    HWND hOrganize, hOrg, hFinish;
    HWND hShow, hProgress;*/
  UINT iCount=0;
  BOOL bFin=FALSE;
  switch(iMsg)
  {
    case WM_CREATE:
    {
      ShowWindow(hMain, SW_SHOW);
      iCount=0;
      do
      {
        vhWin[iCount]=NULL;
        iCount++;
      }
      while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
      SendMessage(hMain, WM_COMMAND, MAKEWPARAM(IDB_NEXT, BN_CLICKED), (LPARAM)vhWin[0]);
    }
      break;
    case WM_PAINT:
    {
      PAINTSTRUCT clPaint;
      HDC hDC=BeginPaint(hMain, &clPaint);
      FillRect(hDC, &clPaint.rcPaint, (HBRUSH)(COLOR_WINDOW+1));
      EndPaint(hMain, &clPaint);
      ReleaseDC(hMain, hDC);
      DeleteDC(hDC);
    }
      break;
    case WM_COMMAND:
    {
      if(HIWORD(wParam)==CBN_SELCHANGE)
      {
        int iIndex=SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
        switch(iIndex)
        {
          case 0:
          {
            clInit.bAuthOrg=TRUE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
            break;
          case 1:
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=TRUE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
            break;
          case 2:
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=TRUE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
            break;
          case 3:
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=TRUE;
            clInit.bDateOrg=FALSE;
          }
            break;
          case 4:
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=TRUE;
          }
            break;
        }
      }
      switch(LOWORD(wParam))
      {
        case IDB_NEXT:
        {
          iCount=0;
          MessageBox(NULL, "Starting Loop Now", "Information", MB_ICONINFORMATION|MB_OK);
          do
          {
            if(IsWindow(vhWin[iCount])!=0)
            {
              DestroyWindow(vhWin[iCount]);
              iCount++;
            }
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          MessageBox(NULL, "Loop Finished", "Information", MB_ICONINFORMATION|MB_OK);
          std::string sIntro=GetIntroText();
          MessageBox(NULL, "Got Intro Text.\nCreating Controls.", "Information", MB_ICONINFORMATION|MB_OK);
          vhWin[1]=CreateWindowEx(0, "Static", sIntro.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                760, 380, hMain, (HMENU)IDC_INT_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[2]=CreateWindowEx(0, "Button", "Okay", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 315, 400,
                                170, 160, hMain, (HMENU)IDB_NEXT1, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_NEXT1:
        {
          clInit.bUserAcc=FALSE;
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
              iCount++;
            }
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sTerms=GetTermsText();
          vhWin[3]=CreateWindowEx(0, "Static", sTerms.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                760, 380, hMain, (HMENU)IDC_TER_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[4]=CreateWindowEx(0, "Button", "Accept", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 20, 400,
                                 170, 160, hMain, (HMENU)IDB_ACCEPT, GetModuleHandle(NULL), NULL);
          vhWin[5]=CreateWindowEx(0, "Button", "Deny", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 210, 400,
                               170, 160, hMain, (HMENU)IDB_DENY, GetModuleHandle(NULL), NULL);
          vhWin[0]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 420, 400,
                                170, 160, hMain, (HMENU)IDB_NEXT, GetModuleHandle(NULL), NULL);
          vhWin[6]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 610, 400,
                                170, 160, hMain, (HMENU)IDB_NEXT2, GetModuleHandle(NULL), NULL);
        }
          break;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
        case IDB_NEXT2:
        {
          if(IsDlgButtonChecked(hMain, IDB_ACCEPT)==BST_UNCHECKED&&IsDlgButtonChecked(hMain, IDB_DENY)==BST_UNCHECKED)
          {
            WPARAM wPar=MAKEWPARAM(IDB_NEXT1, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[1]);
          }
          else if(IsDlgButtonChecked(hMain, IDB_DENY)==BST_CHECKED)
          {
            SendMessage(hMain, WM_CLOSE, 0, 0);
            WPARAM wPar=MAKEWPARAM(IDB_NEXT1, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[1]);
          }
          else
          {
            clInit.bUserAcc=TRUE;
            clInit.bProtect=FALSE;
            iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
                iCount++;
              }
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sAccount=GetAccountText();
            vhWin[7]=CreateWindowEx(0, "Static", sAccount.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                    760, 380, hMain, (HMENU)IDC_USE_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[8]=CreateWindowEx(0, "Button", "Enable User Accounts?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
                                    210, 400, 170, 160, hMain, (HMENU)IDB_PROTECT, GetModuleHandle(NULL), NULL);
            vhWin[2]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 420, 400,
                                    170, 160, hMain, (HMENU)IDB_NEXT1, GetModuleHandle(NULL), NULL);
            vhWin[9]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 610, 400,
                                    170, 160, hMain, (HMENU)IDB_NEXT3, GetModuleHandle(NULL), NULL);
          }
        }
          break;
        case IDB_NEXT3:
        {
          if(IsDlgButtonChecked(hMain, IDB_PROTECT)==BST_UNCHECKED)
          {
            clInit.bUserMem=FALSE;
            clInit.bPassMem=FALSE;
            WPARAM wPar=MAKEWPARAM(IDB_NEXT4, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[1]);
          }
          else
          {
            clInit.bUserMem=FALSE;
            clInit.bPassMem=FALSE;
            iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
                iCount++;
              }
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sMemory=GetMemoryText();
            vhWin[10]=CreateWindowEx(0, "Static", sMemory.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                     760, 380, hMain, (HMENU)IDC_MEM_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[11]=CreateWindowEx(0, "Button", "Remember Username?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 20, 400,
                                     170, 160, hMain, (HMENU)IDB_USER_MEM, GetModuleHandle(NULL), NULL);
            vhWin[12]=CreateWindowEx(0, "Button", "Remember Password?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 210, 400,
                                     170, 160, hMain, (HMENU)IDB_PASS_MEM, GetModuleHandle(NULL), NULL);
            vhWin[6]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 420, 400,
                                    170, 160, hMain, (HMENU)IDB_NEXT2, GetModuleHandle(NULL), NULL);
            vhWin[13]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 610, 400,
                                     170, 160, hMain, (HMENU)IDB_NEXT4, GetModuleHandle(NULL), NULL);
          }
        }
          break;
        case IDB_NEXT4:
        {
          if(IsDlgButtonChecked(hMain, IDB_USER_MEM)==BST_CHECKED)
          {
            clInit.bUserMem=TRUE;
          }
          if(IsDlgButtonChecked(hMain, IDB_PASS_MEM)==BST_CHECKED)
          {
            clInit.bPassMem=TRUE;
          }
          iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
                iCount++;
              }
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sOrganize=GetOrganizeText();
            vhWin[14]=CreateWindowEx(0, "Static", sOrganize.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20,
                                     20, 530, 560, hMain, (HMENU)IDC_ORG_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[15]=CreateWindowEx(0, "Combobox", "", WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS,
                                     570, 20, 210, 160, hMain, (HMENU)IDC_ORG, GetModuleHandle(NULL), NULL);
            std::string sContents[5];
            sContents[0]="Author";
            sContents[1]="Title";
            sContents[2]="Genre";
            sContents[3]="Publisher";
            sContents[4]="Date";
            for(iCount=0; iCount<=4; iCount+=1)
            {
              SendMessage(vhWin[15], CB_ADDSTRING, 0, (LPARAM)sContents[iCount].c_str());
            }
            SendMessage(vhWin[15], CB_SETCURSEL, 0, 0);
            clInit.bAuthOrg=TRUE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
            vhWin[9]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 590,
                                     240, 170, 160, hMain, (HMENU)IDB_NEXT3, GetModuleHandle(NULL), NULL);
            vhWin[16]=CreateWindowEx(0, "Button", "Finish", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 590,
                                     420, 170, 160, hMain, (HMENU)IDB_FINISH, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_FINISH:
        {
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
              iCount++;
            }
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          vhWin[17]=CreateWindowEx(0, "Static", "", WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_CENTER, 20,
                                   220, 760, 160, hMain, (HMENU)IDC_PRO_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[18]=CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD|WS_VISIBLE, 220, 400, 360, 100,
                                   hMain, (HMENU)IDC_BASE_PROGRESS, GetModuleHandle(NULL), NULL);
          SendMessage(vhWin[18], PBM_SETRANGE, 0, MAKELPARAM(0, 11));
          SendMessage(vhWin[18], PBM_SETSTEP, 1, 0);
          SetWindowText(vhWin[17], "Obtaining Desktop Directory");
          char pcDesk[248];
          if(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, pcDesk)==S_OK)
          {
            clPaths.sCur=pcDesk;
            SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
            SetWindowText(vhWin[17], "Obtaining Programs Directory");
            char pcProg[248];
            if(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, pcProg)==S_OK)
            {
              clPaths.sTar=pcProg;
              SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[17], "Creating Current Directory");
              clPaths.sApp="\\VirtLib";
              clPaths.sCur=clPaths.sCur+clPaths.sApp;
              SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[17], "Creating Target Directory");
              clPaths.sTar=clPaths.sTar+clPaths.sApp;
              SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[17], "Obtaining File: init.txt");
              std::string sInit="\\System\\init.txt";
              std::string sDir=clPaths.sCur;
              sDir=sDir+sInit;
              SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[17], "Opening File: init.txt");
              std::fstream cbOpen;
              cbOpen.open(sDir.c_str(), std::ios::out);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
              if(!cbOpen.is_open())
              {
                bFin=TRUE;
                MessageBox(NULL, "Windows could not open a file needed to complete this task.\n"
                           "Please contact the program designer for help regarding this error.",
                           "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
                SendMessage(hMain, WM_CLOSE, 0, 0);
              }
              else
              {
                SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[17], "Writing File: init.txt");
                cbOpen << clInit.bProtect;
                cbOpen << clInit.bUserAcc;
                cbOpen << clInit.bUserMem;
                cbOpen << clInit.bPassMem;
                cbOpen << "\n";
                cbOpen << clInit.bAuthOrg;
                cbOpen << clInit.bTitlOrg;
                cbOpen << clInit.bGenrOrg;
                cbOpen << clInit.bPublOrg;
                cbOpen << clInit.bDateOrg;
                cbOpen << "\n";
                cbOpen << clPaths.sTar;
                SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[17], "Closing File: init.txt");
                cbOpen.close();
                SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[17], "Moving Program Directory");
                if(MoveFile(clPaths.sCur.c_str(), clPaths.sTar.c_str())!=0)
                {
                  SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[17], "Finding Library");
                  std::string sLib="\\System\\lib.exe";
                  std::string sLibPro=clPaths.sTar;
                  std::string sOpening="\\System\\main.exe";
                  std::string sOpenPro=clPaths.sTar;
                  sLibPro=sLibPro+sLib;
                  sOpenPro=sOpenPro+sOpening;
                  SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[17], "Opening Library");
                  if(clInit.bProtect==TRUE)
                  {
                    ShellExecute(NULL, "open", sLibPro.c_str(), NULL, NULL, SW_SHOW);
                  }
                  else
                  {
                    ShellExecute(NULL, "open", sOpenPro.c_str(), NULL, NULL, SW_SHOW);
                  }
                  SendMessage(vhWin[18], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[17], "Finished...Closing");
                  bFin=TRUE;
                  SendMessage(hMain, WM_CLOSE, 0, 0);
                }
                else
                {
                  bFin=TRUE;
                  MessageBox(NULL, "Windows failed to move the program's directory.\n"
                             "Please contact the program designer for help regarding this error.",
                             "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
                  SendMessage(hMain, WM_CLOSE, 0, 0);
                }
              }
            }
            else
            {
              bFin=TRUE;
              MessageBox(NULL, "Windows could not find the desktop directory.\n"
                         "Please contact the program designer for help regarding this error.",
                         "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
              SendMessage(hMain, WM_CLOSE, 0, 0);
            }
          }
          else
          {
            bFin=TRUE;
            MessageBox(NULL, "Windows could not find the desktop directory.\n"
                       "Please contact the program designer for help regarding this error.",
                       "Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
            SendMessage(hMain, WM_CLOSE, 0, 0);
          }
        }
          break;
      }
    }
      break;
    case WM_CLOSE:
    {
      if(IsDlgButtonChecked(hMain, IDB_DENY)==BST_CHECKED)
      {
        DestroyWindow(hMain);
      }
      if(!bFin)
      {
        UINT iRet;
        iRet=MessageBox(NULL, "\n\nIf you quit now your progress will not be saved, "
                        "and you will have to start from the beginning the next time you run this program."
                        "\n\nAre you sure you want to exit the initialization procedure?",
                        "Warning", MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2|MB_SYSTEMMODAL);
        if(iRet==IDNO)
        {
          break;
        }
        else
        {
          DestroyWindow(hMain);
        }
      }
      else
      {
        DestroyWindow(hMain);
      }
    }
      break;
    case WM_DESTROY:
    {
      PostQuitMessage(0);
    }
      break;
    case WM_QUIT:
    {
      DestroyWindow(hMain);
    }
      break;
    default:
      return DefWindowProc(hMain, iMsg, wParam, lParam);
  }
  return 0;
}

std::string GetIntroText()
{
  std::string sTemp="  Welcome to your own personal library. "
"Here you can upload ebooks, keep them all organized neatly in one place, and choose which book to read from the user interface. "
"You can edit details for each book, including: Author, Title, Genre, Publisher, Date Published, and Number of Pages. "
"You can also upload an image, to display as the book cover, within the user interface. "
"If you choose not to upload a book cover, it will be displayed in the library using the title of the book.";
  return sTemp;
}

std::string GetTermsText()
{
  std::string sTemp="Terms of Service:\n\n  The program, hereby referred to as \"software\", shall be given to you, hereby referred to as "
"\"user\", for full functionality within the predefined control of the software. These terms, hereby referred to as \"agreement\", will be "
"considered as an agreement between you, the user, and the creator of this program, hereby referred to as \"designer\". "
"This agreement will cover the following:\n\n"
"1. You the user shall not reverse engineer, modify or redistribute the software without prior consent of the designer.\n"
"2. The terms of this agreement are subject to future changes without further notice. :P";
  return sTemp;
}

std::string GetAccountText()
{
  std::string sTemp="  For added security to your library, you may choose to enable the use of accounts. "
"When you create an account you will choose a user name and password. "
"If you choose to enable this option any books you upload will be visible only within the scope of the user account that uploaded them. "
"IE, you may only view and open books that you uploaded from your own account."
"\n\nWould you like to enable accounts?";
  return sTemp;
}

std::string GetMemoryText()
{
  std::string sTemp="  You have chosen to enable the account protection feature of the library. "
"For convenience of use, you may choose to have the system remember your user name and/or password.\n\n"
"Warning, if you choose to remember your user name AND password, others may be able to sign into your account.";
  return sTemp;
}

std::string GetOrganizeText()
{
  std::string sTemp="  The books uploaded to your library will automatically be organized alphabetically by title. "
"You may choose to have your books organized by one of the following areas instead.\n\n"
"Note: You will be able to change this option later within the library's \"Organize\" menu option.";
  return sTemp;
}
Last edited on
In the actual code written into the editor in the IDE, the GetWhateverText() functions at the bottom are all single quoted strings. I split them into separate lines because it ran very far off the side of the screen in the forum's code tags.

There may be (most likely is) many more bugs/problems within the program. However, it compiles without errors, so right now I'm trying to debug through running it, but it keeps getting stuck (now that modoran helped me fix the original array problem) in the IDB_NEXT case of WM_COMMAND when it gets to the theoretical window destroying loop.

And, whether you (can) help or not, thank you modoran and TTT for your time. It's greatly appreciated.
I think there is infinite loop in your program )))


1
2
3
4
5
6
7
8
9
10
11
iCount=0;
          MessageBox(NULL, "Starting Loop Now", "Information", MB_ICONINFORMATION|MB_OK);
          do
          {
            if(IsWindow(vhWin[iCount])!=0)
            {
              DestroyWindow(vhWin[iCount]);
              iCount++;
            }
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));


your iCount remains 0 so statmenet in while is always right.
So rewrite it like this then try again

1
2
3
4
5
6
7
8
9
10
11
12
iCount=0;
          MessageBox(NULL, "Starting Loop Now", "Information", MB_ICONINFORMATION|MB_OK);
          do
          {
            if(IsWindow(vhWin[iCount])!=0)
            {
              DestroyWindow(vhWin[iCount]);
              
            }
           iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));


This was in case IDB_NEXT
Last edited on
Please make your variables inside your window procedure either static or use global variables (not recommended) as will go out of scope each time the window procedure is called.

1
2
static HWND vhWin[19] = {0};
 static  UINT iCount = 0;
Thank you again TTT.

I didn't realize I had put the increment inside of the if statement...

Note on why I may be missing obvious errors: This whole thing consists of three separate programs, which altogether was supposed to be a Christmas present for someone...obviously, I've missed that deadline. So, I've been driving myself crazy trying to finish it as soon as possible...maybe I just need to take a break XD Also, because this was created for one person in particular, the terms of service part is kind of an inside joke between us (^_^)

And...it now passes through there, and creates the controls. The static control is displayed as an empty frame with no text, but I can most likely fix that. I'm going to take a short break, and look back through.

Note: the size of the "Okay" button was not at all how I seen it in my head, so some of the dimensions on the windows will be changed.

@modoran: Will do, thank you. It was my (obviously wrong) assumption that in win32 programming that once the message loop started the window procedure remained active until it returned 0 to end the loop. I didn't think they would go out of scope like that.
Last edited on
Okay, I'm back now, and after changing the sizes of the controls to look a little better (I haven't finished the missing text problem yet), I clicked through and found a few other small problems. I'll go through and fix everything I can, and re-post the new code when I'm done.

Thank you both very very much.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include <windows.h>
#include <commctrl.h>
#include <math.h>
#include <objbase.h>
#include <shlobj.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <string>

#define IDB_NEXT 01001
#define IDB_NEXT1 01002
#define IDB_ACCEPT 01003
#define IDB_DENY 01004
#define IDB_BACK1 01005
#define IDB_NEXT2 01006
#define IDB_PROTECT 01007
#define IDB_BACK2 01010
#define IDB_NEXT3 01011
#define IDB_USER_MEM 01012
#define IDB_PASS_MEM 01013
#define IDB_BACK3 01014
#define IDB_NEXT4 01015
#define IDB_ORG_AUTH 01016
#define IDB_ORG_TITL 01017
#define IDB_ORG_GENR 01020
#define IDB_ORG_PUBL 01021
#define IDB_ORG_DATE 01022
#define IDB_BACK4 01023
#define IDB_FINISH 01024
#define IDC_INT_STATIC 02001
#define IDC_TER_STATIC 02002
#define IDC_USE_STATIC 02003
#define IDC_MEM_STATIC 02004
#define IDC_ORG_STATIC 02005
#define IDC_ORG 02006
#define IDC_PRO_STATIC 02007
#define IDC_BASE_PROGRESS 02010

LRESULT CALLBACK OpenWinProc(HWND, UINT, WPARAM, LPARAM);
void GetIntroText(std::string&);
void GetTermsText(std::string&);
void GetAccountText(std::string&);
void GetMemoryText(std::string&);
void GetOrganizeText(std::string&);

class clInitial
{
  public:
    BOOL bProtect;
    BOOL bUserAcc;
    BOOL bUserMem;
    BOOL bPassMem;
    BOOL bAuthOrg;
    BOOL bTitlOrg;
    BOOL bGenrOrg;
    BOOL bPublOrg;
    BOOL bDateOrg;
}clInit;

class clPath
{
  public:
    std::string sApp;
    std::string sCur;
    std::string sTar;
}clPaths;

const char sOpen[]="OpenWin";
const char sSys[]="SysWin";

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR sArg, int iShow)
{
  HWND hMain;
  MSG iMsg;
  WNDCLASSEX clOpen;
  clOpen.hInstance=hInstance;
  clOpen.lpszClassName=sOpen;
  clOpen.lpfnWndProc=OpenWinProc;
  clOpen.style=CS_DBLCLKS;
  clOpen.cbSize=sizeof(WNDCLASSEX);
  clOpen.hIcon=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
  clOpen.hCursor=LoadCursor(NULL, IDC_ARROW);
  clOpen.lpszMenuName=NULL;
  clOpen.cbClsExtra=0;
  clOpen.cbWndExtra=0;
  clOpen.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
  if(!RegisterClassEx(&clOpen))
  {
    MessageBox(NULL, "Windows Failed To Register Class.", "Fatal Error",
               MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
    return 0;
  }
  else
  {
    RECT clRect={0, 0, 800, 600};
    AdjustWindowRectEx(&clRect, WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, FALSE, WS_EX_CLIENTEDGE);
    hMain=CreateWindowEx(WS_EX_CLIENTEDGE, sOpen, "Your Virtual Library", WS_OVERLAPPED|WS_BORDER|WS_SYSMENU|WS_CAPTION, CW_USEDEFAULT,
                         CW_USEDEFAULT, clRect.right-clRect.left, clRect.bottom-clRect.top, HWND_DESKTOP, NULL, hInstance, NULL);
    if(hMain==NULL)
    {
      MessageBox(NULL, "Windows Failed To Create Window.", "Fatal Error",
                 MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
      return 0;
    }
    else
    {
      ShowWindow(hMain, iShow);
      UpdateWindow(hMain);
      while(GetMessage(&iMsg, NULL, 0, 0))
      {
        TranslateMessage(&iMsg);
        DispatchMessage(&iMsg);
      }
    }
  }
  return iMsg.wParam;
}

LRESULT CALLBACK OpenWinProc(HWND hMain, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
  static HWND vhWin[27];/*
    HWND hNext;
    HWND hIntro, hNext1;
    HWND hTerms, hAccept, hDeny, hBack1, hNext2;
    HWND hAccount, hProtect, hBack2, hNext3;
    HWND hMemory, hUser, hPass, hBack3, hNext4;
    HWND hOrganize, hAuthor, hTitle, hGenre, hPublisher, hDate, hBack4, hFinish;
    HWND hShow, hProgress;*/
  static UINT iCount=0;
  static BOOL bFin=FALSE;
  switch(iMsg)
  {
    case WM_CREATE:
    {
      ShowWindow(hMain, SW_SHOW);
      iCount=0;
      do
      {
        vhWin[iCount]=NULL;
        iCount++;
      }
      while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
      SendMessage(hMain, WM_COMMAND, MAKEWPARAM(IDB_NEXT, BN_CLICKED), (LPARAM)vhWin[0]);
    }
      break;
    case WM_PAINT:
    {
      PAINTSTRUCT clPaint;
      HDC hDC=BeginPaint(hMain, &clPaint);
      FillRect(hDC, &clPaint.rcPaint, (HBRUSH)(COLOR_WINDOW+1));
      EndPaint(hMain, &clPaint);
      ReleaseDC(hMain, hDC);
      DeleteDC(hDC);
    }
      break;
    case WM_COMMAND:
    {
      switch(LOWORD(wParam))
      {
        case IDB_NEXT:
        {
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount])!=0)
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sIntro;
          GetIntroText(sIntro);
          vhWin[1]=CreateWindowEx(0, "Static", sIntro.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                  760, 490, hMain, (HMENU)IDC_INT_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[2]=CreateWindowEx(0, "Button", "Okay", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 350, 530,
                                  100, 50, hMain, (HMENU)IDB_NEXT1, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_BACK1:
        {
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount])!=0)
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sIntro;
          GetIntroText(sIntro);
          vhWin[1]=CreateWindowEx(0, "Static", sIntro.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                  760, 490, hMain, (HMENU)IDC_INT_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[2]=CreateWindowEx(0, "Button", "Okay", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 350, 530,
                                  100, 50, hMain, (HMENU)IDB_NEXT1, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_NEXT1:
        {
          clInit.bUserAcc=FALSE;
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sTerms;
          GetTermsText(sTerms);
          vhWin[3]=CreateWindowEx(0, "Static", sTerms.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                  760, 490, hMain, (HMENU)IDC_TER_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[4]=CreateWindowEx(0, "Button", "Accept", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 20, 530,
                                  100, 50, hMain, (HMENU)IDB_ACCEPT, GetModuleHandle(NULL), NULL);
          vhWin[5]=CreateWindowEx(0, "Button", "Deny", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 140, 530,
                                  100, 50, hMain, (HMENU)IDB_DENY, GetModuleHandle(NULL), NULL);
          vhWin[6]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                  100, 50, hMain, (HMENU)IDB_BACK1, GetModuleHandle(NULL), NULL);
          vhWin[7]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                  100, 50, hMain, (HMENU)IDB_NEXT2, GetModuleHandle(NULL), NULL);
        }
          break;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
        case IDB_BACK2:
        {
          clInit.bUserAcc=FALSE;
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sTerms;
          GetTermsText(sTerms);
          vhWin[3]=CreateWindowEx(0, "Static", sTerms.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                  760, 490, hMain, (HMENU)IDC_TER_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[4]=CreateWindowEx(0, "Button", "Accept", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 20, 530,
                                  100, 50, hMain, (HMENU)IDB_ACCEPT, GetModuleHandle(NULL), NULL);
          vhWin[5]=CreateWindowEx(0, "Button", "Deny", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 140, 530,
                                  100, 50, hMain, (HMENU)IDB_DENY, GetModuleHandle(NULL), NULL);
          vhWin[6]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                  100, 50, hMain, (HMENU)IDB_BACK1, GetModuleHandle(NULL), NULL);
          vhWin[7]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                  100, 50, hMain, (HMENU)IDB_NEXT2, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_NEXT2:
        {
          if(IsDlgButtonChecked(hMain, IDB_ACCEPT)==BST_UNCHECKED&&IsDlgButtonChecked(hMain, IDB_DENY)==BST_UNCHECKED)
          {
            WPARAM wPar=MAKEWPARAM(IDB_BACK2, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[10]);
          }
          else if(IsDlgButtonChecked(hMain, IDB_DENY)==BST_CHECKED)
          {
            SendMessage(hMain, WM_CLOSE, 0, 0);
            WPARAM wPar=MAKEWPARAM(IDB_BACK2, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[10]);
          }
          else
          {
            clInit.bUserAcc=TRUE;
            clInit.bProtect=FALSE;
            iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
              }
              iCount++;
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sAccount;
            GetAccountText(sAccount);
            vhWin[8]=CreateWindowEx(0, "Static", sAccount.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                    760, 490, hMain, (HMENU)IDC_USE_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[9]=CreateWindowEx(0, "Button", "Enable User Accounts?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
                                    20, 530, 200, 50, hMain, (HMENU)IDB_PROTECT, GetModuleHandle(NULL), NULL);
            vhWin[10]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                    100, 50, hMain, (HMENU)IDB_BACK2, GetModuleHandle(NULL), NULL);
            vhWin[11]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                    100, 50, hMain, (HMENU)IDB_NEXT3, GetModuleHandle(NULL), NULL);
          }
        }
          break;
        case IDB_BACK3:
        {
          clInit.bUserMem=FALSE;
          clInit.bPassMem=FALSE;
          clInit.bProtect=FALSE;
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sAccount;
          GetAccountText(sAccount);
          vhWin[8]=CreateWindowEx(0, "Static", sAccount.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                  760, 490, hMain, (HMENU)IDC_USE_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[9]=CreateWindowEx(0, "Button", "Enable User Accounts?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
                                  20, 530, 200, 50, hMain, (HMENU)IDB_PROTECT, GetModuleHandle(NULL), NULL);
          vhWin[10]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                  100, 50, hMain, (HMENU)IDB_BACK2, GetModuleHandle(NULL), NULL);
          vhWin[11]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                  100, 50, hMain, (HMENU)IDB_NEXT3, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_NEXT3:
        {
          if(IsDlgButtonChecked(hMain, IDB_PROTECT)==BST_UNCHECKED)
          {
            clInit.bProtect=FALSE;
            clInit.bUserMem=FALSE;
            clInit.bPassMem=FALSE;
            WPARAM wPar=MAKEWPARAM(IDB_NEXT4, BN_CLICKED);
            SendMessage(hMain, WM_COMMAND, wPar, (LPARAM)vhWin[16]);
          }
          else
          {
            clInit.bProtect=TRUE;
            clInit.bUserMem=FALSE;
            clInit.bPassMem=FALSE;
            iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
              }
              iCount++;
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sMemory;
            GetMemoryText(sMemory);
            vhWin[12]=CreateWindowEx(0, "Static", sMemory.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                     760, 490, hMain, (HMENU)IDC_MEM_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[13]=CreateWindowEx(0, "Button", "Remember Username?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 20, 530,
                                     200, 50, hMain, (HMENU)IDB_USER_MEM, GetModuleHandle(NULL), NULL);
            vhWin[14]=CreateWindowEx(0, "Button", "Remember Password?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 220, 530,
                                     200, 50, hMain, (HMENU)IDB_PASS_MEM, GetModuleHandle(NULL), NULL);
            vhWin[15]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                    100, 50, hMain, (HMENU)IDB_BACK3, GetModuleHandle(NULL), NULL);
            vhWin[16]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                     100, 50, hMain, (HMENU)IDB_NEXT4, GetModuleHandle(NULL), NULL);
          }
        }
          break;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
        case IDB_BACK4:
        {
          if(clInit.bProtect==FALSE)
          {
            SendMessage(hMain, WM_COMMAND, MAKEWPARAM(IDB_BACK3, BN_CLICKED), (LPARAM)vhWin[15]);
          }
          else
          {
            clInit.bUserMem=FALSE;
            clInit.bPassMem=FALSE;
            iCount=0;
            do
            {
              if(IsWindow(vhWin[iCount]))
              {
                DestroyWindow(vhWin[iCount]);
              }
              iCount++;
            }
            while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
            std::string sMemory;
            GetMemoryText(sMemory);
            vhWin[12]=CreateWindowEx(0, "Static", sMemory.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20, 20,
                                     760, 490, hMain, (HMENU)IDC_MEM_STATIC, GetModuleHandle(NULL), NULL);
            vhWin[13]=CreateWindowEx(0, "Button", "Remember Username?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 20, 530,
                                     200, 50, hMain, (HMENU)IDB_USER_MEM, GetModuleHandle(NULL), NULL);
            vhWin[14]=CreateWindowEx(0, "Button", "Remember Password?", WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, 220, 530,
                                     200, 50, hMain, (HMENU)IDB_PASS_MEM, GetModuleHandle(NULL), NULL);
            vhWin[15]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 560, 530,
                                    100, 50, hMain, (HMENU)IDB_BACK3, GetModuleHandle(NULL), NULL);
            vhWin[16]=CreateWindowEx(0, "Button", "Next", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 680, 530,
                                     100, 50, hMain, (HMENU)IDB_NEXT4, GetModuleHandle(NULL), NULL);
          }
        }
          break;
        case IDB_NEXT4:
        {
          if(IsDlgButtonChecked(hMain, IDB_USER_MEM)==BST_CHECKED)
          {
            clInit.bUserMem=TRUE;
          }
          if(IsDlgButtonChecked(hMain, IDB_PASS_MEM)==BST_CHECKED)
          {
            clInit.bPassMem=TRUE;
          }
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          std::string sOrganize;
          GetOrganizeText(sOrganize);
          vhWin[17]=CreateWindowEx(0, "Static", sOrganize.c_str(), WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_LEFT, 20,
                                   20, 530, 560, hMain, (HMENU)IDC_ORG_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[18]=CreateWindowEx(0, "Button", "Author", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 625, 20,
                                   100, 50, hMain, (HMENU)IDB_ORG_AUTH, GetModuleHandle(NULL), NULL);
          SendMessage(vhWin[18], BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
          clInit.bAuthOrg=TRUE;
          clInit.bTitlOrg=FALSE;
          clInit.bGenrOrg=FALSE;
          clInit.bPublOrg=FALSE;
          clInit.bDateOrg=FALSE;
          vhWin[19]=CreateWindowEx(0, "Button", "Title", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 625, 90,
                                   100, 50, hMain, (HMENU)IDB_ORG_TITL, GetModuleHandle(NULL), NULL);
          vhWin[20]=CreateWindowEx(0, "Button", "Genre", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 625, 150,
                                   100, 50, hMain, (HMENU)IDB_ORG_GENR, GetModuleHandle(NULL), NULL);
          vhWin[21]=CreateWindowEx(0, "Button", "Publisher", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 625, 210,
                                   100, 50, hMain, (HMENU)IDB_ORG_PUBL, GetModuleHandle(NULL), NULL);
          vhWin[22]=CreateWindowEx(0, "Button", "Date", WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, 625, 270,
                                   100, 50, hMain, (HMENU)IDB_ORG_DATE, GetModuleHandle(NULL), NULL);
          vhWin[23]=CreateWindowEx(0, "Button", "Back", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 625,
                                  410, 100, 50, hMain, (HMENU)IDB_BACK4, GetModuleHandle(NULL), NULL);
          vhWin[24]=CreateWindowEx(0, "Button", "Finish", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, 625,
                                   530, 100, 50, hMain, (HMENU)IDB_FINISH, GetModuleHandle(NULL), NULL);
        }
          break;
        case IDB_FINISH:
        {
          if(IsDlgButtonChecked(hMain, IDB_ORG_AUTH)==BST_CHECKED)
          {
            clInit.bAuthOrg=TRUE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
          else if(IsDlgButtonChecked(hMain, IDB_ORG_TITL)==BST_CHECKED)
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=TRUE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
          else if(IsDlgButtonChecked(hMain, IDB_ORG_GENR)==BST_CHECKED)
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=TRUE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=FALSE;
          }
          else if(IsDlgButtonChecked(hMain, IDB_ORG_PUBL)==BST_CHECKED)
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=TRUE;
            clInit.bDateOrg=FALSE;
          }
          else if(IsDlgButtonChecked(hMain, IDB_ORG_DATE)==BST_CHECKED)
          {
            clInit.bAuthOrg=FALSE;
            clInit.bTitlOrg=FALSE;
            clInit.bGenrOrg=FALSE;
            clInit.bPublOrg=FALSE;
            clInit.bDateOrg=TRUE;
          }
          iCount=0;
          do
          {
            if(IsWindow(vhWin[iCount]))
            {
              DestroyWindow(vhWin[iCount]);
            }
            iCount++;
          }
          while(iCount<sizeof(vhWin)/sizeof(vhWin[0]));
          vhWin[25]=CreateWindowEx(0, "Static", "", WS_CHILD|WS_VISIBLE|SS_BLACKFRAME|SS_CENTER, 20,
                                   220, 760, 160, hMain, (HMENU)IDC_PRO_STATIC, GetModuleHandle(NULL), NULL);
          vhWin[26]=CreateWindowEx(0, PROGRESS_CLASS, "", WS_CHILD|WS_VISIBLE, 220, 400, 100, 50,
                                   hMain, (HMENU)IDC_BASE_PROGRESS, GetModuleHandle(NULL), NULL);
          SendMessage(vhWin[26], PBM_SETRANGE, 0, MAKELPARAM(0, 11));
          SendMessage(vhWin[26], PBM_SETSTEP, 1, 0);
          SetWindowText(vhWin[25], "Obtaining Desktop Directory");
          char pcDesk[248];
          if(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, pcDesk)==S_OK)
          {
            clPaths.sCur=pcDesk;
            SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
            SetWindowText(vhWin[25], "Obtaining Programs Directory");
            char pcProg[248];
            if(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, pcProg)==S_OK)
            {
              clPaths.sTar=pcProg;
              SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[25], "Creating Current Directory");
              clPaths.sApp="\\VirtLib";
              clPaths.sCur=clPaths.sCur+clPaths.sApp;
              SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[25], "Creating Target Directory");
              clPaths.sTar=clPaths.sTar+clPaths.sApp;
              SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[25], "Obtaining File: init.txt");
              std::string sInit="\\System\\init.txt";
              std::string sDir=clPaths.sCur;
              sDir=sDir+sInit;
              SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
              SetWindowText(vhWin[25], "Opening File: init.txt");
              std::fstream cbOpen;
              cbOpen.open(sDir.c_str(), std::ios::out);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
if(!cbOpen.is_open())
              {
                bFin=TRUE;
                MessageBox(NULL, "Windows could not open a file needed to complete this task.\n"
                           "Please contact the program designer for help regarding this error.",
                           "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
                SendMessage(hMain, WM_CLOSE, 0, 0);
              }
              else
              {
                SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[25], "Writing File: init.txt");
                cbOpen << clInit.bProtect;
                cbOpen << clInit.bUserAcc;
                cbOpen << clInit.bUserMem;
                cbOpen << clInit.bPassMem;
                cbOpen << "\n";
                cbOpen << clInit.bAuthOrg;
                cbOpen << clInit.bTitlOrg;
                cbOpen << clInit.bGenrOrg;
                cbOpen << clInit.bPublOrg;
                cbOpen << clInit.bDateOrg;
                cbOpen << "\n";
                cbOpen << clPaths.sTar;
                SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[25], "Closing File: init.txt");
                cbOpen.close();
                SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                SetWindowText(vhWin[25], "Moving Program Directory");
                if(MoveFile(clPaths.sCur.c_str(), clPaths.sTar.c_str())!=0)
                {
                  SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[25], "Finding Library");
                  std::string sLib="\\System\\lib.exe";
                  std::string sLibPro=clPaths.sTar;
                  std::string sOpening="\\System\\main.exe";
                  std::string sOpenPro=clPaths.sTar;
                  sLibPro=sLibPro+sLib;
                  sOpenPro=sOpenPro+sOpening;
                  SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[25], "Opening Library");
                  if(clInit.bProtect==TRUE)
                  {
                    ShellExecute(NULL, "open", sLibPro.c_str(), NULL, NULL, SW_SHOW);
                  }
                  else
                  {
                    ShellExecute(NULL, "open", sOpenPro.c_str(), NULL, NULL, SW_SHOW);
                  }
                  SendMessage(vhWin[26], PBM_STEPIT, 0, 0);
                  SetWindowText(vhWin[25], "Finished...Closing");
                  bFin=TRUE;
                  SendMessage(hMain, WM_CLOSE, 0, 0);
                }
                else
                {
                  bFin=TRUE;
                  MessageBox(NULL, "Windows failed to move the program's directory.\n"
                             "Please contact the program designer for help regarding this error.",
                             "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
                  SendMessage(hMain, WM_CLOSE, 0, 0);
                }
              }
            }
            else
            {
              bFin=TRUE;
              MessageBox(NULL, "Windows could not find the desktop directory.\n"
                         "Please contact the program designer for help regarding this error.",
                         "Fatal Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
              SendMessage(hMain, WM_CLOSE, 0, 0);
            }
          }
          else
          {
            bFin=TRUE;
            MessageBox(NULL, "Windows could not find the desktop directory.\n"
                       "Please contact the program designer for help regarding this error.",
                       "Error", MB_ICONERROR|MB_OK|MB_DEFBUTTON1|MB_SYSTEMMODAL);
            SendMessage(hMain, WM_CLOSE, 0, 0);
          }
        }
          break;
      }
    }
      break;
    case WM_CLOSE:
    {
      if(IsDlgButtonChecked(hMain, IDB_DENY)==BST_CHECKED)
      {
        DestroyWindow(hMain);
      }
      if(!bFin)
      {
        UINT iRet;
        iRet=MessageBox(NULL, "\n\nIf you quit now your progress will not be saved, "
                        "and you will have to start from the beginning the next time you run this program."
                        "\n\nAre you sure you want to exit the initialization procedure?",
                        "Warning", MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2|MB_SYSTEMMODAL);
        if(iRet==IDNO)
        {
          break;
        }
        else
        {
          DestroyWindow(hMain);
        }
      }
      else
      {
        DestroyWindow(hMain);
      }
    }
      break;
    case WM_DESTROY:
    {
      PostQuitMessage(0);
    }
      break;
    case WM_QUIT:
    {
      DestroyWindow(hMain);
    }
      break;
    default:
      return DefWindowProc(hMain, iMsg, wParam, lParam);
  }
  return 0;
}

void GetIntroText(std::string& sTemp)
{
  sTemp="  Welcome to your own personal library. \
Here you can upload ebooks, keep them all organized neatly in one place, and choose which book to read from the user interface. \
You can edit details for each book, including: Author, Title, Genre, Publisher, Date Published, and Number of Pages. \
You can also upload an image, to display as the book cover, within the user interface. \
If you choose not to upload a book cover, it will be displayed in the library using the title of the book.";
  return;
}

void GetTermsText(std::string& sTemp)
{
  sTemp="Terms of Service:\n\n  The program, hereby referred to as \"software\", shall be given to you, hereby referred to as \
\"user\", for full functionality within the predefined control of the software. These terms, hereby referred to as \"agreement\", \
will be considered as an agreement between you, the user, and the creator of this program, hereby referred to as \"designer\". \
This agreement will cover the following:\n\n\
1. You the user shall not reverse engineer, modify or redistribute the software without prior consent of the designer.\n\
2. The terms of this agreement are subject to future changes without further notice. :P";
  return;
}

void GetAccountText(std::string& sTemp)
{
  sTemp="  For added security to your library, you may choose to enable the use of accounts. \
When you create an account you will choose a user name and password. \
If you choose to enable this option any books you upload will be visible only within the scope of the user account that uploaded them. \
IE, you may only view and open books that you uploaded from your own account.\n\n\
Would you like to enable accounts?";
  return;
}

void GetMemoryText(std::string& sTemp)
{
  sTemp="  You have chosen to enable the account protection feature of the library. \
For convenience of use, you may choose to have the system remember your user name and/or password. \
Warning, if you choose to remember your user name AND password, others may be able to sign into your account.";
  return;
}

void GetOrganizeText(std::string& sTemp)
{
  sTemp="  The books uploaded to your library will automatically be organized alphabetically by title. \
You may choose to have your books organized by one of the following areas instead.\n\n\
Note: You will be able to change this option later within the library's \"Organize\" menu option.";
  return;
}


Right now, this is the unedited code I have. I've tried using WM_SETTEXT and SetWindowText as opposed to using c_str() in the CreateWindowEx() calls. However, nothing has worked and the static controls remain textless. I have used std::fstream to open a file and write the string to it just before calling CreateWindowEx(). The string contains the text from the function, however it won't display.

Edit: I figured out the missing text problem. The text doesn't display when the SS_BLACKFRAME style is defined.

I've updated the sizes of the static controls, and the buttons. I've added in actual "Back" buttons, rather than simulating the "Next" button from 2 sections back like before. It was easier to do it this way to keep track of clearing specific variables, etc when going backwards rather than forwards.
Last edited on
I've got everything done now, thank you, thank you, thank you (^_^)
Topic archived. No new replies allowed.