The header file code
Public:
Virtual void ontouch * pDC (CDC);
Void Drawx * pDC (CDC);
Drawxy2 ();//used by dynamically create protected constructor
Virtual ~ drawxy2 ();
Void BgetDC ();
The CDC * pDC.
Program to define the code
Void drawxy2: : ontouch * pDC (CDC)
{
CDocument * pDoc=GetDocument ();
PDC - & gt; MoveTo (0, 0);
PDC - & gt; LineTo (1000100);//TODO: add in this rendering code
}
Void drawxy2: : Drawx (pDC) CDC *
{
PDC - & gt; MoveTo (0, 0);
PDC - & gt; LineTo (1000100);
}
The main program code
Void main ()
{
Drawxy2 drawx1;
HDC HDDC=: : GetDC (0);
The CDC DDC;
DDC. Attach (HDDC);
Drawx1. Drawx (& amp; DDC);
Drawx1. Ontouch (& amp; DDC);
}
Seek help from a great god
CodePudding user response:
Suggest the win32 application first learn to write well?Don't blindly,
Recommend a book, "a simple MFC
"A lot of online electronic,
CodePudding user response:
Fyi:# pragma comment (lib, "user32")
# pragma comment (lib, "gdi32")
#include
#include
#include
Extern "C" HWND WINAPI GetConsoleWindow ();
Void HideTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=FALSE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Void ShowTheCursor () {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut=GetStdHandle (STD_OUTPUT_HANDLE);
If (GetConsoleCursorInfo (hStdOut, & amp; CciCursor)) {
CciCursor. BVisible=TRUE;
SetConsoleCursorInfo (hStdOut, & amp; CciCursor);
}
}
Int main () {
The HWND HWND;
HDC HDC.
HFONT HFONT;
System (" color F0 ");
System (" CLS ");
HideTheCursor ();
HWND=GetConsoleWindow ();
HDC=GetDC (HWND);
Hfont=CreateFont (48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Chinese regular script");
SelectObject (HDC, hfont);
TextOut (HDC, 10, 10, "the earth person all know!" , 14);
MoveToEx (HDC, 5, 5, NULL);
The LineTo (HDC, 300, 5);
The LineTo (HDC, 300, 60);
The LineTo (HDC, 5, 60);
The LineTo (HDC, 5, 5);
DeleteObject (hfont);
ReleaseDC (HWND, HDC);
Getchar ();
07 system (" color ");
System (" CLS ");
ShowTheCursor ();
return 0;
}
CodePudding user response:
I also want to lay a solid foundation, but the teacher lets get this one, also is helpless,I now aim is to build a class, and then through a call to this class to draw a simple graphics (rectangle, circle, linear, whatever), then I just inherited a view class, name drawxy2, it defines the two Shared a member function, and the runtime is not an error but not in figure, I consider whether I get the CDC didn't pass, or I in this class defines the less things,
Just want to know the place, can draw a line out, bothering me all day
Thank you for the great god help
CodePudding user response:
Must be HWND HWND=GetConsoleWindow ();Then you can do
Typedef HWND (WINAPI * PROCGETCONSOLEWINDOW) ();
PROCGETCONSOLEWINDOW GetConsoleWindow;
Int main ()
{//vc6
Kernel32 HMODULE hKernel32=GetModuleHandle (" ");
GetConsoleWindow=(PROCGETCONSOLEWINDOW) GetProcAddress call (hKernel32, "GetConsoleWindow");
HWND HWND=GetConsoleWindow ();
HDC HDC=GetDC (HWND);
////////////////////////////////////////////////////////
CodePudding user response:
You should not use the console (main) engineering, should use the win32 projectCodePudding user response:
The written code, as a console application, and as with c #, also derived a cview, seems to be the MFC, is actually the archaeological travesty,A little hint, the MFC document view in the program structure, not add a CView casually, can draw a diagram to, want to with a document view framework combining ability, otherwise you need to put aside the document view structure,
CodePudding user response:
Object-oriented is a kind of programming ideas,To abstract programming language, is not the last into the assembly code? It is fair to say the assembler language is object oriented, scripting, dynamic, functional, parallel and distributed language,