1、windows的窗口是怎么实现的?HWND代表windows窗口对象,里面究竟什么数据?怎么实现显示的?用C和GDI做个类似的例子演示下
2、关于C语言强制转换,数据精度方面的问题关于问题1,一直做windows方面的开发没想过用c和gdi实现窗口,关于问题2我不知道有没有讲C语言实现方面的好书,市面的书都是讲怎么用c,这些东西怎么能困扰我这么久呢???
2、关于C语言强制转换,数据精度方面的问题关于问题1,一直做windows方面的开发没想过用c和gdi实现窗口,关于问题2我不知道有没有讲C语言实现方面的好书,市面的书都是讲怎么用c,这些东西怎么能困扰我这么久呢???
解决方案 »
- 求《Visual C++界面编程技术》的电子书 (收到后马上给分!)
- 关于托盘编程的一个问题………………………………请大虾们指导。谢谢了!!
- 在vc6里面一用stl,就满屏的警告,太恐怖了
- GB -> BIG5 的算法
- 大侠们,小的有请~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- out_of_range怎么用,需要#include什么吗?
- MP3文件格式及如何操作MP3文件?高分送上!K!K!K!K!
- 小问题(阴沟里翻船,只有24分了)
- 关于 combo box
- 如何设置MFC项目中CDockablePane不能改变大小,但是可移动(移动后也不能改变大小)
- 怎么修改VC的编译器的背景
- GDI+ DrawImage 放大图片 边缘透明 问题
===============
这个还真是很难知道,不过也没必要知道,系统自己的事,另外用C和GDI肯定实现不了窗口的。2、关于C语言强制转换,数据精度方面的问题
=============================
这个不知道如何回答
VC中int和float都是4个字节,他们每个比特位表示的意义都不一样。
要是懂汇编的话你看下面链接估计会清楚一些。
http://blog.csdn.net/lights_joy/archive/2009/09/09/4534660.aspx
HWND类似指针,但是里面的数据结构是什么样子的,不知道,没有文档说明的,MS内部定义的。2、关于C语言强制转换,数据精度方面的问题
这个你可以看看MSDN,或许有一些说明的
简易楼主看《windows核心编程》,程序员的圣经。
// sdfsd.cpp : Defines the entry point for the application.
//#include "stdafx.h"
#include "resource.h"#define MAX_LOADSTRING 100// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable; // Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_SDFSD, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance); // Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
} hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SDFSD); // Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} return msg.wParam;
}//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SDFSD);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_SDFSD;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex);
}//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd)
{
return FALSE;
} ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd); return TRUE;
}//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// 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)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE; case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
我虽然用MFC开发,但是自学的路线也很自然:
c/c++&windows程序设计&深入浅出MFC&windwos核心编程&COM&DB&网络,书看了不少了,当然这些年看这么多书显然太匆匆,书一字一字的看,但是没有给自己消化的时间,因此效果不怎么样,windows核心编程里面并没有讲这些机制
windows核心编程讲的够深入吗?讲了windows的窗口实现了吗?没弄明白我的问题吧
B b = new B();
A a = (A)b;按照数学集合的概念,如果 B 属于 A,那就不丢失精度了。否则,就丢失。
楼主的问题我答不出来,至于HWND这个索引所指向的数据结构,更是找不到。
楼主的钻研精神我很欣赏,不过,感觉有点钻的方向不太对了。
探究windows窗口机制内幕是因为曾经花了很多时间研究OLE的实地激活特性,没彻底搞清楚实现机制,当时的感觉就是OLE挺复杂并且与windows窗口机制混在一起了,微软开发的OS,内幕很清楚,所以要实现复杂有用的技术自然很容易,如果去用接口开发自然容易些。现在的工作要用到COM,想起了之前没弄明白的OLE实地激活技术,心里不是滋味呀。所以现在有感而发
C++ 窗口对象和 HWND 之间的关系
窗口对象
窗口“对象”是由程序直接创建的 C++ CWnd 类(或者派生类)的对象。它随程序调用构造函数和析构函数而创建和销毁。而 Windows“窗口”是内部 Windows 数据结构的不透明句柄,它对应于窗口并且在存在时消耗系统资源。Windows 窗口由“窗口句柄”(HWND) 标识并在调用 CWnd 类的 Create 成员函数创建 CWnd 对象之后创建。此窗口可要么由程序调用销毁要么通过用户操作销毁。此窗口句柄存储在窗口对象的 m_hWnd 成员变量中。
看过了,这本书确实不错,但算不上是windows c/c++ 程序员的圣经,只是windows c/c++开发方面的小部分
你也清楚一个窗口背后有完整的消息机制等等...windows不是ms吹出来的.看看外面的世界,比如X Window的实现机制. 实现方法还是很多的.