标题:编译 连接都没有问题 执行就出错了 内存不能read什么的 c++绘图问题 求指 ...
只看楼主
vc小白
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-9-25
结帖率:100%
 问题点数:0 回复次数:2 
编译 连接都没有问题 执行就出错了 内存不能read什么的 c++绘图问题 求指教
#include<windows.h>
#include<stdlib.h>
#include<string.h>
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
    MSG Message;
    if(!InitWindowsClass(hInstance))
        return FALSE;
    if(!InitWindows(hInstance,nCmdShow))
        return FALSE;
    while(GetMessage(&Message,0,0,0))
    {
        TranslateMessage(&Message);
        DispatchMessage(&Message);

    }
     return Message.wParam ;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
    HDC hDC;
    HBRUSH hBrush;
    HPEN hPen;
    PAINTSTRUCT PtStr;
    switch(iMessage)
    {
       case WM_PAINT:
            hDC=BeginPaint(hWnd,&PtStr);
            SetMapMode(hDC,MM_ANISOTROPIC);
            hPen=(HPEN)GetStockObject(DKGRAY_BRUSH);
            SelectObject(hDC,hBrush);
            SelectObject(hDC,hPen);
            RoundRect(hDC,50,120,100,200,15,15);
            hBrush=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
            SelectObject(hDC,hBrush);
            Ellipse(hDC,150,50,200,150);
            hBrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
            SelectObject(hDC,hBrush);
            Pie(hDC,250,50,300,100,250,50,300,50);
            EndPaint(hWnd,&PtStr);
            return 0;
       case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
       default:
              return(DefWindowProc(hWnd,iMessage,wParam,lParam));
    }
}
  

BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
    HWND hWnd;
    hWnd=CreateWindow("WinFill",
                      "填充示例程序",
                      WS_OVERLAPPEDWINDOW,
                      CW_USEDEFAULT,
                      0,
                      CW_USEDEFAULT,
                      0,
                      NULL,
                      NULL,
                      hInstance,
                      NULL);
   
    if(!hWnd)
        return FALSE;
        ShowWindow(hWnd,nCmdShow);
        UpdateWindow(hWnd);
        return TRUE;



}


BOOL InitWindowsClass(HINSTANCE hInstance)
{
    WNDCLASS WndClass;
    WndClass.cbClsExtra=0;
    WndClass.cbWndExtra =0;
    WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
    WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
    WndClass.hIcon=LoadIcon(NULL,"END");
    WndClass.hInstance=hInstance;
    WndClass.lpfnWndProc=WndProc;
    WndClass.lpszClassName="WinFill";
    WndClass.lpszClassName=NULL;
    WndClass.style=CS_HREDRAW|CS_VREDRAW;
    return RegisterClass(&WndClass);
}
搜索更多相关主题的帖子: while return include 内存 
2011-10-04 16:15
vc小白
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-9-25
得分:0 
是不是我新装系统的 原因啊 光看没反应??大家伙都说说啊
2011-10-04 16:52
vc小白
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-9-25
得分:0 
#include<windows.h>
#include<stdlib.h>
#include<string.h>
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
    MSG Message;
    if(!InitWindowsClass(hInstance))
        return FALSE;
    if(!InitWindows(hInstance,nCmdShow))
        return FALSE;
    while(GetMessage(&Message,0,0,0))
    {
        TranslateMessage(&Message);
        DispatchMessage(&Message);

    }
     return Message.wParam ;
}
long WINAPI WndProc(HWND hWnd,UINT iMessage,UINT wParam,LONG lParam)
{
    HDC hDC;
    HBRUSH hBrush;
    HPEN hPen;
    PAINTSTRUCT PtStr;
    switch(iMessage)
    {
       case WM_PAINT:
            hDC=BeginPaint(hWnd,&PtStr);
            SetMapMode(hDC,MM_ANISOTROPIC);
            hPen=(HPEN)GetStockObject(DKGRAY_BRUSH);
            SelectObject(hDC,hBrush);
            SelectObject(hDC,hPen);
            RoundRect(hDC,50,120,100,200,15,15);
            hBrush=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
            SelectObject(hDC,hBrush);
            Ellipse(hDC,150,50,200,150);
            hBrush=(HBRUSH)GetStockObject(HOLLOW_BRUSH);
            SelectObject(hDC,hBrush);
            Pie(hDC,250,50,300,100,250,50,300,50);
            EndPaint(hWnd,&PtStr);
            return 0;
       case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
       default:
              return(DefWindowProc(hWnd,iMessage,wParam,lParam));
    }
}
 

BOOL InitWindows(HINSTANCE hInstance,int nCmdShow)
{
    HWND hWnd;
    hWnd=CreateWindow("WinFill",
                      "填充示例程序",
                      WS_OVERLAPPEDWINDOW,
                      CW_USEDEFAULT,
                      0,
                      CW_USEDEFAULT,
                      0,
                      NULL,
                      NULL,
                      hInstance,
                      NULL);
   
    if(!hWnd)
        return FALSE;
        ShowWindow(hWnd,nCmdShow);
        UpdateWindow(hWnd);
        return TRUE;



}


BOOL InitWindowsClass(HINSTANCE hInstance)
{
    WNDCLASS WndClass;
    WndClass.cbClsExtra=0;
    WndClass.cbWndExtra=0;
    WndClass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
    WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
    WndClass.hIcon=LoadIcon(NULL,"END");
    WndClass.hInstance=hInstance;
    WndClass.lpfnWndProc=WndProc;
    WndClass.lpszClassName="WinFill";
    WndClass.lpszMenuName=NULL;
    WndClass.style=CS_HREDRAW|CS_VREDRAW;
    return RegisterClass(&WndClass);
}


自己挖的坑自己埋上  感谢论坛里的大神
2011-10-12 16:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-351574-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017004 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved