在C 中呼叫系統API使窗體下擁有陰影效果

2021-04-20 03:35:08 字數 741 閱讀 4986

2007-12-16 00:09

昨天晚上看msdn看見的一段通過使用setclasslong函式使視窗下面擁有乙個陰影效果,研究**找資料弄了半個小時把它運用在了c#2.0上,特此一貼。

using system.runtime.interopservices;

然後再視窗類的隨便哪個地方加上:

const int cs_dropshadow = 0x20000;

const int gcl_style = (-26);

//宣告win32 api

[dllimport("user32.dll", charset = charset.auto)]

public static extern int setclasslong(intptr hwnd,int nindex,int dwnewlong);

[dllimport("user32.dll", charset = charset.auto)]

public static extern int getclasslong(intptr hwnd, int nindex);

最後在窗體的建構函式中加上:

setclasslong(this.handle, gcl_style, getclasslong(this.handle, gcl_style) | cs_dropshadow);

編譯程式並執行,窗體陰影效果出來了。哦,忘記說了,陰影效果僅支援win2000/xp/2003。vista自帶窗體陰影,所以不在此例。

在C 中呼叫API的基本過程

首先,在呼叫api之前,你必須先導入system.runtime.interopservices這個命名空間。該命名空間包含了在visual c 中呼叫api的一些必要集合,具體的方法如下 using system.runtime.interopservices dllimport kernel32...

c 開發中mdi子窗體如何呼叫父窗體中控制項

在子視窗中宣告父視窗物件即可進行呼叫例如,父視窗為mdiparent1 子視窗為mdi 只需在mdi 中,需要呼叫父視窗的地方宣告該物件即可,方法如下 public partial class mdi form private void mdi activated object sender,eve...

在C中呼叫C 函式

由於c編譯器與c 編譯器之間的區別十分巨大,因此二者之間不可以直接互相呼叫各自的函式介面。但是,使用extern c 可以實現在c 中呼叫c 函式的功能,反之亦可。extern c 告訴c 編譯器,將花括號中的 按照c語言的規則進行編譯與鏈結。cppprint.cpp cppprint.h call...