Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在win32 c++;应用程序_C++_Winapi - Fatal编程技术网

C++ 如何在win32 c++;应用程序

C++ 如何在win32 c++;应用程序,c++,winapi,C++,Winapi,我对Win32 c++编程相当陌生,我一直在用有限的技能尝试做以下工作 我试图在c++中通过win32窗口打开网页,我通过以下命令找到了解决方案: ShellExecute(0, 0, L"http://www.google.com", 0, 0 , SW_SHOW ); 但这不是一个有用的工具,因为它在内置浏览器(Chrome)上工作,我有一个代码,在窗口上显示一个简单的“Hello world!” // GT_HelloWorldWin32.cpp // compile with: /D_

我对Win32 c++编程相当陌生,我一直在用有限的技能尝试做以下工作

我试图在c++中通过win32窗口打开网页,我通过以下命令找到了解决方案:

ShellExecute(0, 0, L"http://www.google.com", 0, 0 , SW_SHOW );
但这不是一个有用的工具,因为它在内置浏览器(Chrome)上工作,我有一个代码,在窗口上显示一个简单的“Hello world!”

// GT_HelloWorldWin32.cpp
// compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c

#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>

// Global variables

// The main window class name.
static TCHAR szWindowClass[] = _T("win32app");

// The string that appears in the application's title bar.
static TCHAR szTitle[] = _T("Win32 Guided Tour Application");

HINSTANCE hInst;

// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

    if (!RegisterClassEx(&wcex))
    {
        MessageBox(NULL,
            _T("Call to RegisterClassEx failed!"),
            _T("Win32 Guided Tour"),
            NULL);

        return 1;
    }

    hInst = hInstance; // Store instance handle in our global variable

    // The parameters to CreateWindow explained:
    // szWindowClass: the name of the application
    // szTitle: the text that appears in the title bar
    // WS_OVERLAPPEDWINDOW: the type of window to create
    // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
    // 500, 100: initial size (width, length)
    // NULL: the parent of this window
    // NULL: this application does not have a menu bar
    // hInstance: the first parameter from WinMain
    // NULL: not used in this application
    HWND hWnd = CreateWindow(
        szWindowClass,
        szTitle,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT,
        500, 100,
        NULL,
        NULL,
        hInstance,
        NULL
    );

    if (!hWnd)
    {
        MessageBox(NULL,
            _T("Call to CreateWindow failed!"),
            _T("Win32 Guided Tour"),
            NULL);

        return 1;
    }

    // The parameters to ShowWindow explained:
    // hWnd: the value returned from CreateWindow
    // nCmdShow: the fourth parameter from WinMain
    ShowWindow(hWnd,
        nCmdShow);
    UpdateWindow(hWnd);
    ShowWindow(hWnd,
        nCmdShow);
    UpdateWindow(hWnd);

    // Main message loop:
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int) msg.wParam;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("Hello, World!");

    switch (message)
    {
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

        // Here your application is laid out.
        // For this introduction, we just print out "Hello, World!"
        // in the top left corner.
        TextOut(hdc,
            5, 5,
            greeting, _tcslen(greeting));

        // End application-specific layout section.

        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}
//GT\u HelloWorldWin32.cpp
//使用:/D_UNICODE/DUNICODE/DWIN32/D_WINDOWS/c编译
#包括
#包括
#包括
#包括
//全局变量
//主窗口类名称。
静态TCHAR szWindowClass[]=“win32app”);
//显示在应用程序标题栏中的字符串。
静态TCHAR szTitle[]=“Win32导游应用程序”);
HINSTANCE hInst;
//转发此代码模块中包含的函数声明:
LRESULT回调WndProc(HWND、UINT、WPARAM、LPARAM);
int WINAPI WinMain(HINSTANCE HINSTANCE,
HINSTANCE HPPrevenstance,
LPSTR lpCmdLine,
国际展览(nCmdShow)
{
WNDCLASSEX wcex;
wcex.cbSize=sizeof(WNDCLASSEX);
wcex.style=CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc=WndProc;
wcex.cbClsExtra=0;
wcex.cbWndExtra=0;
wcex.hInstance=hInstance;
wcex.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_应用程序));
wcex.hCursor=LoadCursor(空,IDC_箭头);
wcex.hbrBackground=(HBRUSH)(彩色窗口+1);
wcex.lpszMenuName=NULL;
wcex.lpszClassName=szWindowClass;
wcex.hIconSm=LoadIcon(wcex.hInstance,MAKEINTRESOURCE(IDI_应用程序));
如果(!RegisterClassEx(&wcex))
{
MessageBox(空,
_T(“调用RegisterClassEx失败!”),
_T(“Win32导览”),
无效);
返回1;
}
hInst=hInstance;//将实例句柄存储在全局变量中
//CreateWindow的参数解释如下:
//szWindowClass:应用程序的名称
//szTitle:出现在标题栏中的文本
//WS_OVERLAPPEDWINDOW:要创建的窗口类型
//CW_使用默认值,CW_使用默认值:初始位置(x,y)
//500、100:初始尺寸(宽度、长度)
//NULL:此窗口的父级
//NULL:此应用程序没有菜单栏
//hInstance:WinMain的第一个参数
//NULL:此应用程序中未使用
HWND HWND=CreateWindow(
szWindowClass,
szTitle,
WS_重叠窗口,
CW_USEDEFAULT,CW_USEDEFAULT,
500, 100,
无效的
无效的
hInstance,
无效的
);
如果(!hWnd)
{
MessageBox(空,
_T(“调用CreateWindow失败!”),
_T(“Win32导览”),
无效);
返回1;
}
//ShowWindow的参数解释如下:
//hWnd:从CreateWindow返回的值
//nCmdShow:WinMain的第四个参数
展示窗口(hWnd,
nCmdShow);
更新窗口(hWnd);
展示窗口(hWnd,
nCmdShow);
更新窗口(hWnd);
//主消息循环:
味精;
while(GetMessage(&msg,NULL,0,0))
{
翻译信息(&msg);
发送消息(&msg);
}
返回(int)msg.wParam;
}
//
//功能:WndProc(HWND、UINT、WPARAM、LPARAM)
//
//用途:处理主窗口的消息。
//
//WM_绘制-绘制主窗口
//WM_DESTROY-发布退出消息并返回
//
//
LRESULT回调WndProc(HWND HWND,UINT消息,WPARAM WPARAM,LPARAM LPARAM)
{
PAINTSTRUCT-ps;
HDC-HDC;
TCHAR问候语[]=“你好,世界!”;
开关(信息)
{
案例WM_油漆:
hdc=开始喷漆(hWnd和ps);
//这是你的申请表。
//在本简介中,我们只需打印“你好,世界!”
//在左上角。
文本输出(hdc,
5, 5,
问候语;
//结束特定于应用程序的布局部分。
端漆(hWnd和ps);
打破
案例WM_销毁:
PostQuitMessage(0);
打破
违约:
返回DefWindowProc(hWnd、message、wParam、lParam);
打破
}
返回0;
}
但我的要求是在Hello world的地方通过自己的应用程序窗口打开网页

如果有人拥有sol plz股份


谢谢

这相当复杂。有一篇文章展示了如何


在这里

您想编写一个web浏览器吗?@Axalo:我只想在显示hello World的窗口上呈现网页。我想您需要使用一些
ActiveX
控件。@SanjeevSangral,我在上一篇评论中给出了一个链接。而且还有一个是@SanjeevSangral,欢迎光临。具有一种溶液的斯塔奇科夫流