Monday, June 05, 2006

Hack a EditBox with just a ES_PASSWORD style set

This is the Workingcode for it

BOOL CALLBACK EnumWindowsProc(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value);

BOOL CALLBACK EnumChildProc1(HWND hwnd,LPARAM lParam );

//BN_CLICKED handler
void CTrwDlg::OnButton1() {
::EnumWindows (EnumWindowsProc,0);
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value)
{
::EnumChildWindows (hwnd,EnumChildProc1,0);
return TRUE;
}

BOOL CALLBACK EnumChildProc1(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value)
{
::SendMessage (hwnd,EM_SETPASSWORDCHAR,0,0);
HDC hDC = ::GetDC (hwnd);
::SendMessage (hwnd,WM_PAINT,WPARAM(hDC) ,0); // to create invalidation
return TRUE;
}

No comments: