Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUpdateAllViews Pin
sawerr2-Jun-08 0:35
sawerr2-Jun-08 0:35 
AnswerRe: UpdateAllViews Pin
SandipG 2-Jun-08 1:13
SandipG 2-Jun-08 1:13 
GeneralRe: UpdateAllViews Pin
sawerr2-Jun-08 1:32
sawerr2-Jun-08 1:32 
GeneralRe: UpdateAllViews Pin
SandipG 2-Jun-08 1:38
SandipG 2-Jun-08 1:38 
GeneralRe: UpdateAllViews Pin
sawerr2-Jun-08 1:48
sawerr2-Jun-08 1:48 
GeneralRe: UpdateAllViews Pin
SandipG 2-Jun-08 1:57
SandipG 2-Jun-08 1:57 
AnswerRe: UpdateAllViews Pin
Nelek2-Jun-08 4:43
protectorNelek2-Jun-08 4:43 
QuestionA Simple Password Generator Pin
Werty fool2-Jun-08 0:27
Werty fool2-Jun-08 0:27 
Hi everyone, I've been trying to make a simple password generator such that when i enter a number and click generate, a random string of
alphanumeric characters is generated. my problem is every time i click generate, only 1 letter seems to appear. Any help will be greatly appreciated. Source code is as follows:

#include <windows.h>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include "resource.h"

BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:

SetDlgItemInt(hwnd, ID_PASSWORD,1, FALSE);

case WM_COMMAND:
switch(wParam)
{
case ID_GENERATE:
{
char alpha[80]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
char passwrd[80]="";
int numChars = GetWindowTextLength(GetDlgItem(hwnd, ID_PASSWORD));
if(numChars > 0)
{
// Now we allocate, and get the string into our buffer
srand(static_cast<unsigned>(time(0)));

for (int n=0; n<numchars; n++)<br="" mode="hold"> {
int x;
x = 0 + int(61.0 * rand()/(RAND_MAX+1.0));
passwrd[n]= alpha[x];
}

This is the main problem -----------------> MessageBox(NULL, passwrd, "Word Generated", MB_OK);

int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)passwrd);


GlobalFree((HANDLE)passwrd);
}
else
{
MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
}
}
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc);
}
AnswerRe: A Simple Password Generator Pin
CPallini2-Jun-08 0:52
mveCPallini2-Jun-08 0:52 
AnswerRe: A Simple Password Generator Pin
James R. Twine2-Jun-08 2:54
James R. Twine2-Jun-08 2:54 
GeneralRe: A Simple Password Generator Pin
Werty fool2-Jun-08 5:32
Werty fool2-Jun-08 5:32 
QuestionApplication Crashes while shutting down service. Pin
andspeed1-Jun-08 23:58
andspeed1-Jun-08 23:58 
AnswerRe: Application Crashes while shutting down service. Pin
CDP18022-Jun-08 0:28
CDP18022-Jun-08 0:28 
GeneralRe: Application Crashes while shutting down service. Pin
andspeed2-Jun-08 9:17
andspeed2-Jun-08 9:17 
AnswerRe: Application Crashes while shutting down service. Pin
SandipG 2-Jun-08 1:17
SandipG 2-Jun-08 1:17 
Questiondll problem Pin
prithaa1-Jun-08 23:52
prithaa1-Jun-08 23:52 
AnswerRe: dll problem Pin
prithaa2-Jun-08 0:00
prithaa2-Jun-08 0:00 
GeneralRe: dll problem Pin
Graham Shanks2-Jun-08 2:50
Graham Shanks2-Jun-08 2:50 
QuestionAbout Read and Receive new message Pin
savitri1-Jun-08 23:17
savitri1-Jun-08 23:17 
AnswerRe: About Read and Receive new message Pin
Cedric Moonen1-Jun-08 23:44
Cedric Moonen1-Jun-08 23:44 
JokeRe: About Read and Receive new message Pin
Rajesh R Subramanian1-Jun-08 23:48
professionalRajesh R Subramanian1-Jun-08 23:48 
GeneralRe: About Read and Receive new message Pin
savitri2-Jun-08 0:07
savitri2-Jun-08 0:07 
GeneralRe: About Read and Receive new message Pin
Cedric Moonen2-Jun-08 0:41
Cedric Moonen2-Jun-08 0:41 
GeneralRe: About Read and Receive new message Pin
Rajesh R Subramanian2-Jun-08 0:59
professionalRajesh R Subramanian2-Jun-08 0:59 
AnswerRe: About Read and Receive new message Pin
_AnsHUMAN_ 2-Jun-08 0:22
_AnsHUMAN_ 2-Jun-08 0:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.