Home > Software engineering >  After things in WIN32 read a file, how to do character recognition processing (a big problem, for he
After things in WIN32 read a file, how to do character recognition processing (a big problem, for he

Time:11-08

To achieve the theme function, main is to make its own file formats.
As follows, is a button code
 typedef struct tagBTNX 
{//
The HWND HWND;//handle of the owner window
BOOL x1;//default is 185
BOOL x2.//default is 170
BOOL rcx1;
BOOL rcy1;
LPWSTR in;
COLORREF CRF.
UINT style;
} BTN_PARAMX;
//
//
LRESULT a CALLBACK BTProcX (HWND HWND, UINT Msg, WPARAM WPARAM, LPARAM LPARAM)
{//
PAINTSTRUCT ps;
HDC HDC=NULL;
The RECT rc;
GetClientRect (hWnd, & amp; Rc);
LOGFONT lf.
HFONT HFONT=0;
HBRUSH br;
TCHAR TXT [40].
//TODO:
//here, it reads the RGB. TXT
/*
We assume that the main. TXT content is
The Button [RGB,42,51 (37), TEXT (TEXT)]
*/
Char * buffer;
Char * bufferB;
HANDLE hFile;//define a handle,
HFile=CreateFileA (" is the main. TXT ",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL.
NULL);//use CreatFile this API function to open the file
DWORD dwDataLen;
Char FileContent [100].
ReadFile (hFile, FileContent, 100, & amp; DwDataLen, NULL);//read the data
The FileContent [dwDataLen]=0;//set zero array without end,
The CloseHandle (hFile);//close the handle

The switch (Msg)
{//
In case the WM_PAINT:
{

//MessageBoxA (0, FileContent, "NOTHING", 0).//output
//MessageBox (NULL, NULL, NULL, NULL);
HDC=BeginPaint (hWnd, & amp; Ps);
Br=CreateSolidBrush (RGB (/* here after loading identification of RGB. TXT in the RGB values, 37,42,51 */));
FillRect (HDC, & amp; Rc, br);
GetWindowText (hWnd, TXT, 40);
SetBkMode (HDC, TRANSPARENT);
SetTextColor (HDC, TEXTBLACK);
If (hFont==0)
{
Memset (& amp; Lf, 0, sizeof (LOGFONT));
Lf. LfHeight=- 16;
Wcscpy (lf) lfFaceName, L "bold");
HFont=CreateFontIndirect (& amp; Lf);//create the font
}
HFONT old=(HFONT) SelectObject (HDC, HFONT);
TextOut (HDC, 18, 7, TXT, wcslen (TXT)/* & amp; Ps. RcPaint *//* DT_SINGLELINE | DT_CENTER | DT_VCENTER */);
//DrawText (HDC, TXT, wcslen (TXT), & amp; Ps. RcPaint DT_SINGLELINE | DT_CENTER | DT_VCENTER);
ReleaseDC (hWnd, HDC);
UpdateWindow (hWnd);
//DeleteObject (br);
EndPaint (hWnd, & amp; Ps);
break;
}
Case WM_MOUSEMOVE:
{
TRACKMOUSEEVENT tme.
Tme. CbSize=sizeof (tme);
Tme. DwFlags=TME_HOVER | TME_LEAVE;
Tme. DwHoverTime=1;
Tme. HwndTrack=hWnd;
BOOL boRet=_TrackMouseEvent (& amp; Tme);
} break;
Case WM_MOUSELEAVE:
{

//PAINTSTRUCT ps1.
HBRUSH gets;
HDC=GetDC (hWnd);
Gets=CreateSolidBrush (RGB (/* here after loading identification of RGB. TXT in the RGB values, 37,42,51 */));
SelectObject (HDC, gets);
FillRect (HDC, & amp; Rc, gets);
GetWindowText (hWnd, TXT, 40);
SetTextColor (HDC, TEXTBLACK);
SetBkMode (HDC, TRANSPARENT);
If (hFont==0)
{
Memset (& amp; Lf, 0, sizeof (LOGFONT));
Lf. LfHeight=- 16;
Wcscpy (lf) lfFaceName, L "bold");
HFont=CreateFontIndirect (& amp; Lf);//create the font
}
HFONT old=(HFONT) SelectObject (HDC, HFONT);
TextOut (HDC, 18, 7, TXT, wcslen (TXT)/* & amp; Ps. RcPaint *//* DT_SINGLELINE | DT_CENTER | DT_VCENTER */);
//SetWindowText (hWnd, L "closed");
ReleaseDC (hWnd, HDC);
DeleteObject (gets);
OutputDebugStringA (" Leave \ n ");
break;
}
Case WM_MOUSEHOVER:
{
HBRUSH gets=NULL;
HDC=GetDC (hWnd);
Gets=CreateSolidBrush (RGB (99, 184, 255));
SelectObject (HDC, gets);
FillRect (HDC, & amp; Rc, gets);
GetWindowText (hWnd, TXT, 40);
SetTextColor (HDC, TEXTBLACK);
SetBkMode (HDC, TRANSPARENT);
If (hFont==0)
{
Memset (& amp; Lf, 0, sizeof (LOGFONT));
Lf. LfHeight=- 16;
Wcscpy (lf) lfFaceName, L "bold");
HFont=CreateFontIndirect (& amp; Lf);//create the font
}
HFONT old=(HFONT) SelectObject (HDC, HFONT);
TextOut (HDC, 18, 7, TXT, wcslen (TXT)/* & amp; Ps. RcPaint *//* DT_SINGLELINE | DT_CENTER | DT_VCENTER */);
//SetWindowText (hWnd, L "closed");
ReleaseDC (hWnd, HDC);
//SetWindowText (hWnd, L "[closed]");
DeleteObject (gets);
OutputDebugStringA (" Over \ n ");
break;
}
}
//
Return CallWindowProc (BToldProc hWnd, Msg, wParam, lParam);
}
//if the need for message processing, case IDC_XX:
//TODO: just said main. TXT in the TEXT (TEXT), the create button below will show the things
Int ButtonEx (
The HWND HWND,//handle of the owner window
BOOL x1,
BOOL x2,
BOOL rcx1,
BOOL rcy1,
UINT style//button control dependence was obtained from the definition
)
{
The static HFONT HFONT;
BTN_PARAMX BTN.
BTN. HWnd=hWnd;
BTN. Style=style;
G_bt1=CreateWindow (L "Button", the TEXT/* to read the file () in the characters */, WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_OWNERDRAW,//the default Button style
X1, x2, rcx1 rcy1 hWnd, (HMENU) style, b_hInstance, NULL);
ButtonProc=(WNDPROC) SetWindowLong (g_bt1 GWL_WNDPROC, (LONG) BTProcX);
return -1;
}


Ditto code, want to do something TODO comment the
Invocation style
# define the Button 0 x10c1
ButtonEx (x, y, x area, area of y, the Button).
As above, so after the implementation, the button will with color as RGB37, 42 ploidy shows the background of "words"

CodePudding user response:

Basic file read and write operations can be read from the file
 
#include
#include nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related