Hello.I'm trying to whrite code that depending on entered character ,change the content of the edit controls.The problem is that entered values must be hidden.On the dialog window must be displayed only edit controls .How can I do this.
Windows edit controls represent an instantiation of one of several predefined Window Classes. Other examples of predefined controls would be list boxes, combo boxes, labels (static), progress bars, etc. Every window in Windows is a member or instantiation of some Window Class, and, and one of the most important fields or 'members' of the WNDCLASSEX object is the WNDCLASSEX::lpfnWndProc member.
When someone hits a key on the keyboard, that keystroke will be received in the Window Procedure of an edit control - if the edit control has the keyboard focus. The Window Procedure for the edit control will receive WM_CHAR and WM_KEYDOWN messages. It is those messages that you want to get at. For example, if someone presses the letter 'a' and you want a 'b' instead to show up in the edit control, then you'll want to intercept the WM_CHAR message and translate the 'a' into a 'b'.
The way you do this is by 'subclassing' the edit control. Windows contains a function named SetWindowLong()/SetWindowLongPtr(), and if the GWL_WNDPROC define is used as a parameter, it allows you to intercept the messages bound for the internal Window Procedure within Windows of the edit control, and substitute your own. That is how you an modify the behavior of the edit control (or any control). Do a search for 'Window Subclassing', and you should find examples of it.
I've learnt a lot about subclassing , but my code doesn't work as I want.
The idea is depending on entered character in edit control3 to increase the value of edit control1 or edit control2.Here is the code:
#include "stdafx.h"
#include "table6.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK MyEditProc(HWND ,UINT ,WPARAM ,LPARAM);
INT_PTR CALLBACK Table(HWND, UINT, WPARAM, LPARAM);
WNDPROC g_pOldProc;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
It would help if you would use code tags fitipaldi, so that others could look at decently formatted code.
I did look at your code though, and suspect this might be your problem in your subclass procedure MyEditProc ...
if(chChar=='h')
Since chChar is defined as a TCHAR, if you are doing a wide character build, it won't make a satisfactory comparison of a wide character against an ansi character. I'd recommend you try this instead ...