注: 不是说用 那个 std::cout 出来
有真正界面并可以用鼠标来操作
8 个解决方案
#1
需要借助GUI库,可以选择Qt或者是GTK+库。
#2
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
PAINTSTRUCT ps;
HDC hdc;
HFONT hfont,ohfont;
RECT r;
COLORREF oc;
switch(message) {
case WM_CLOSE://按Alt+F4退出
PostQuitMessage(0);
break;
case WM_PAINT:
BeginPaint(hWnd, &ps);
hdc = ps.hdc; // the device context to draw in
GetClientRect(hWnd, &r); // Obtain the window's client rectangle
hfont = CreateFont(240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "华文楷体");
ohfont=SelectObject(hdc,hfont);
oc=SetTextColor(hdc,0x00C080FF);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc,r.left+r.right/2-720, r.top+r.bottom/2-120,"最短画图程序",12);
SelectObject(hdc,ohfont);
SetTextColor(hdc,oc);
DeleteObject(hfont);
EndPaint(hWnd, &ps);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MSG msg = {0};
WNDCLASS wc = {0};
HBRUSH hbrh;
hbrh=CreateSolidBrush(0x00000000);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hbrBackground = hbrh;
wc.lpszClassName = "minwindowsapp";
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
if( FAILED(RegisterClass(&wc)) ) return 1;
if(FAILED(CreateWindow(wc.lpszClassName,
"Minimal Windows Application",
WS_POPUP|WS_VISIBLE,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
0,
0,
hInstance,
NULL)))
return 2;
while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) {
DispatchMessage( &msg );
}
DeleteObject(hbrh);
return 0;
}
Line and Curve Functions
The following functions are used with lines and curves.
AngleArc
Arc
ArcTo
GetArcDirection
LineDDA
LineDDAProc
LineTo
MoveToEx
PolyBezier
PolyBezierTo
PolyDraw
Polyline
PolylineTo
PolyPolyline
SetArcDirection
Filled Shape Functions
The following functions are used with filled shapes.
Chord
Ellipse
FillRect
FrameRect
InvertRect
Pie
Polygon
PolyPolygon
Rectangle
RoundRect
#3
WM_LBUTTONUP
The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_LBUTTONUP
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return Values
If an application processes this message, it should return zero.
Remarks
An application can use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
WM_MOUSEMOVE
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Remarks
The MAKEPOINTS macro can be used to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture
The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_LBUTTONUP
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return Values
If an application processes this message, it should return zero.
Remarks
An application can use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
WM_MOUSEMOVE
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Remarks
The MAKEPOINTS macro can be used to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture
#4
其实有一些开源库的图像处理效果更好的!
Opencv这些
Qt也挺好的
Opencv这些
Qt也挺好的
#5
MSDN98\SAMPLES\VC98\MFC\TUTORIAL\SCRIBBLE\STEP1~7\*.*
#6
win32窗体界面。基于消息循环。就可以了。
#7
你估计没有使用IDE。。。。使用QT CREATOR拖拉一个按钮到界面就好了。右键》》slot >>click ..直接写事件代码..走ok兰..
#8
c++要入界面,MFC、QT不解释
#1
需要借助GUI库,可以选择Qt或者是GTK+库。
#2
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
PAINTSTRUCT ps;
HDC hdc;
HFONT hfont,ohfont;
RECT r;
COLORREF oc;
switch(message) {
case WM_CLOSE://按Alt+F4退出
PostQuitMessage(0);
break;
case WM_PAINT:
BeginPaint(hWnd, &ps);
hdc = ps.hdc; // the device context to draw in
GetClientRect(hWnd, &r); // Obtain the window's client rectangle
hfont = CreateFont(240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "华文楷体");
ohfont=SelectObject(hdc,hfont);
oc=SetTextColor(hdc,0x00C080FF);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc,r.left+r.right/2-720, r.top+r.bottom/2-120,"最短画图程序",12);
SelectObject(hdc,ohfont);
SetTextColor(hdc,oc);
DeleteObject(hfont);
EndPaint(hWnd, &ps);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MSG msg = {0};
WNDCLASS wc = {0};
HBRUSH hbrh;
hbrh=CreateSolidBrush(0x00000000);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hbrBackground = hbrh;
wc.lpszClassName = "minwindowsapp";
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
if( FAILED(RegisterClass(&wc)) ) return 1;
if(FAILED(CreateWindow(wc.lpszClassName,
"Minimal Windows Application",
WS_POPUP|WS_VISIBLE,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
0,
0,
hInstance,
NULL)))
return 2;
while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) {
DispatchMessage( &msg );
}
DeleteObject(hbrh);
return 0;
}
Line and Curve Functions
The following functions are used with lines and curves.
AngleArc
Arc
ArcTo
GetArcDirection
LineDDA
LineDDAProc
LineTo
MoveToEx
PolyBezier
PolyBezierTo
PolyDraw
Polyline
PolylineTo
PolyPolyline
SetArcDirection
Filled Shape Functions
The following functions are used with filled shapes.
Chord
Ellipse
FillRect
FrameRect
InvertRect
Pie
Polygon
PolyPolygon
Rectangle
RoundRect
#3
WM_LBUTTONUP
The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_LBUTTONUP
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return Values
If an application processes this message, it should return zero.
Remarks
An application can use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
WM_MOUSEMOVE
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Remarks
The MAKEPOINTS macro can be used to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture
The WM_LBUTTONUP message is posted when the user releases the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_LBUTTONUP
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return Values
If an application processes this message, it should return zero.
Remarks
An application can use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN
WM_MOUSEMOVE
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.
WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
Parameters
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Remarks
The MAKEPOINTS macro can be used to convert the lParam parameter to a POINTS structure.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
See Also
Mouse Input Overview, Mouse Input Messages, GetCapture,MAKEPOINTS,POINTS, SetCapture
#4
其实有一些开源库的图像处理效果更好的!
Opencv这些
Qt也挺好的
Opencv这些
Qt也挺好的
#5
MSDN98\SAMPLES\VC98\MFC\TUTORIAL\SCRIBBLE\STEP1~7\*.*
#6
win32窗体界面。基于消息循环。就可以了。
#7
你估计没有使用IDE。。。。使用QT CREATOR拖拉一个按钮到界面就好了。右键》》slot >>click ..直接写事件代码..走ok兰..
#8
c++要入界面,MFC、QT不解释