用getDC(0)获得屏幕DC后,如何释放. 得到电脑屏幕的宽和高

用getDC(0)获得屏幕DC后,如何释放.

2007-02-10 15:51 starwsk  |  分类:其他编程语言  |  浏览6332次
对不起,忘了说了.我学的是VB,
屏幕!!,不是其它场景
我有更好的答案
提问者采纳
检举| 2007-02-13 08:47
After painting with a common device context, the ReleaseDC function must be called to release the device context. 

This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context. 

int ReleaseDC( 
  HWND hWnd, 
  HDC hDC
); 
Parameters
hWnd 
Handle to the window whose device context is to be released. 
hDC 
Handle to the device context to be released. 
Return Values
The return value specifies whether the device context is released. 

1 indicates that the device context is released. 

Zero indicates that the device context is not released.

Remarks
The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context. 

An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function. 

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winuser.h.
Link Library: Coredll.lib, Winmgr.lib.

//这跟你学的什么语言有什么关系,,API一样可以调用啊,,
只要是getDC返回的,,,都可以用 ReleaseDC 释放,,
屏幕的句柄为0,,所以ReleaseDC的时候第一个参数也为0

参考资料:MSDN


vc中怎样得到电脑屏幕的宽和高?

2009-09-14 19:26匿名  |  分类:VC++  |  浏览1318次
vc中怎样得到电脑屏幕的宽和高?然后将应用程序的主窗口在第一次运行出来的位置在自己想要的位置,谢谢指教!
我有更好的答案
提问者采纳
检举| 2009-09-14 20:12
Visual C++中获取屏幕宽和高的函数为GetSystemMetrics(int nIndex),其结果为像素值。其中索引值nIndex在获取屏幕宽时为SM—CXSCREEN,在获取屏幕高时为SM—CYSCREEN。举例如下: 

  BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 

  { // 设置窗口风格 

  //... 

  // 设置窗口位置 

   cs.x=GetSystemMetrics(SM—CXSCREEN) /2; 

   cs.y=GetSystemMetrics(SM—CYSCREEN) /2; 

   //设置窗口的宽和高(屏幕宽和高的一半) 

   cs.cx=GetSystemMetrics(SM—CXSCREEN)/2; 

   cs.cy=GetSystemMetrics(SM—CYSCREEN)/2; 

   return CFrameWnd::PreCreateWindow(cs);} 
在第一次运行出来的位置在自己想要的位置
用MoveWindow 和SetWindowPos
SetWindowPos可以完成MoveWindow的功能,也能完成MoveWindow不能完成的功能   
  MoveWindow只是移动窗口的位置和大小   
    
  SetWindowPos还可以设置窗口的Z-ORDER、显示隐藏窗口等等


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值