C, Win32 API: l need help here

Hi, Good day everyone.
l have some difficulties in the following which l need some help. Am a learner in win32 programming.

1. l created an application with a button "LogOut", which l want, when the user clicks the LogOut button, the application starts afresh. Just like in a standard program(eg. MSWORD) where when "New" is clicked, a new workspace pops out. So l need help in making my program to start afresh when LogOut button is clicked.

MY TRIAL:

l had done the following, and it worked but it only run the codes in WM_CREATE and l still had sent messages to other cases like WM_PAINT, WM_NOTIFY etc, still only the code in WM_CREATE runs.
1
2
3
case IDC_LOGOUTBTN:
     SendMessage(hWnd,WM_CREATE, 0,(LPARAM)lpcs)//where lpcs is a pointer to CreateStruct structure.
break;


2. At some point in my program, l generate random numbers using srand((unsigned)time(&t)) and rand() functions when NEXT button is clicked. But l want to know if there is anyway to get the previous random number(s) when PREVIOUS button is clicked?

Thanks.
Last edited on
OP wrote:
l had done the following, and it worked but it only run the codes in WM_CREATE and l still had sent messages to other cases like WM_PAINT, WM_NOTIFY etc, still only the code in WM_CREATE runs.


Well yeah, that's what the 'break' statement does. It tells the program to stop evaluating your condition against the other cases in your switch and exit the statement block. If you want to test your condition against the rest of the switch cases then ditch the 'break;'.

2. At some point in my program, l generate random numbers using srand((unsigned)time(&t)) and rand() functions when NEXT button is clicked. But l want to know if there is anyway to get the previous random number(s) when PREVIOUS button is clicked?

Save them to a vector as they are generated. This will be the most straightforward way of doing this.
Topic archived. No new replies allowed.