GetClassName函数怎么用呀?

pale 2002-06-07 04:28:40
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
LPTSTR classname;
if(GetClassName(m_hWnd,classname,20)==0) AfxMessageBox("not received class name");
}

老是说找不到,我这样做不对吗?
...全文
713 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
pale 2002-06-09
  • 打赏
  • 举报
回复
我的问题基本解决了,我是在父进程中直接得到那个控件的HWND,然后想法将这个值传给子进程就可以了,现在的问题就是怎么进行两个进程间的数据传递问题了!

现在先给这个贴子结贴,给分!
有关进程间数据传递的问题在下面的贴子里,有时间帮看看!
谢谢帮助
http://www.csdn.net/expert/topic/790/790222.xml?temp=.8401758
pale 2002-06-07
  • 打赏
  • 举报
回复
非常感谢,我现在不得不走了,来不及给分了
我一定会给分的
相信我!
我还想用这个贴子再问问清楚!
再次感谢!
pale 2002-06-07
  • 打赏
  • 举报
回复
第二个参数呢?
你是说直接将那个ID号从SPY++中查出来然后填数字,是吧?
papaya_stone 2002-06-07
  • 打赏
  • 举报
回复

第一个参数标明了要找的主窗口。tt就是呀。
pale 2002-06-07
  • 打赏
  • 举报
回复
我就是用的GetDlgItem
可里面的ID号程序提示说未定义
也确实

这个函数是在子进程里使用的,而ID是父进程里的
这该怎么办?
谢谢
papaya_stone 2002-06-07
  • 打赏
  • 举报
回复
用这个也成
HWND GetDlgItem(
HWND hDlg, // handle of dialog box
int nIDDlgItem // identifier of control
);
不过要知道控件的ID,用spy++可以查到。
papaya_stone 2002-06-07
  • 打赏
  • 举报
回复
tt是主窗口句柄,要找到其中控件的句柄用FindWindowEx()函数,
具体如何用看看MSDN吧。
pale 2002-06-07
  • 打赏
  • 举报
回复
非常感谢
想再问一个问题
我在另一个进程里要用到我刚才得到的对话框的一个fram控件的HWND
LPCTSTR classname="#32770";
CWnd tt;
tt=FindWindow(classname,NULL);
if(tt==NULL) AfxMessageBox("not find win");
HWND hPreviewWnd;
hPreviewWnd=tt->GetDlgItem(IDC_STATIC_PREVIEW2)->m_hWnd;
//IDC_STATIC_PREVIEW2是那个对话框中的一个控件

这样写是不对的,因为IDC_STATIC_PREVIEW2在这个进程里并不存在,
那应该怎么写?
再次表示感谢?

一会就给分,谢谢!
papaya_stone 2002-06-07
  • 打赏
  • 举报
回复
"#32770"就是一般对话框的类名。

可以用VC的工具spy++来察看窗口的属性。

(^_^)
pale 2002-06-07
  • 打赏
  • 举报
回复
谢谢
回复人: papaya_stone(^_^)shentong(^_^)

得到的是“#32770”,这是类名字吗?
我可以在其他的程序中用这个来获取HWND吗?
比如说用FindWindow?
papaya_stone 2002-06-07
  • 打赏
  • 举报
回复
没有为classname分配空间。

void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
char classname[20]="\0";
if(GetClassName(m_hWnd,classname,20)==0) AfxMessageBox("not received class name");
}
WINAPI,WinAPI手册,最全的WINAPI函数手册,WINAPI开发必备 目录 1 内容简介 14 前言 14 第一章 Win32 API概论 14 为什么使用 Wiu32 API 14 Win32 API 简介 15 第二章 窗口管理函数 16 第一节 易用特性函数(Accessibility Features) 20 SoundSentryProc 20 SystemParametersinfo 21 第二节 按钮函数(Button) 34 CheckDlgButton 34 CheckRadioButton 34 IsDlgButtonChecked 35 第三节 插入标记(^)函数(Caret) 36 CreateCaret 36 DestroyCaret 37 GetCaretBlinkTime 37 GetCaretPos 38 HideCaret 38 SetCaretBlinkTime 39 SetCaretPos 39 ShowCaret 40 第四节 组合框函数(Combo box) 40 CCHookProc 40 CFHookProc 42 ChooseColor 43 ChooseFont 44 CommDlgExtendedEorror 45 DlgDirListComboBox 47 DlgDirSelectEx 49 DlgDirSelectComboBoxEx 50 FindText 50 FRHookProc 51 GetFileTitle 52 GetOpenFileName 53 GetSaveFileName 54 OFNGookProc 54 OFNHookProcOldStyle 56 PagePaintHook 57 PageSetupDlg 58 pageSetupHook 58 PrintDlg 59 PrintdlgEx 60 PrintHookProc 61 ReplaceText 62 SetupHookProc 63 第五节 标函数(Cursor) 64 ClipCursor 64 CopyCursor 65 CreateCursor 65 DestroyCursor 66 GetClipCursor 67 GetCursor 67 GetCursorpos 67 LoadCursorFromFile 68 SetCursor 68 SetCursorPos 69 SetSystemCursor 69 ShowCursor 70 LoadCursor 71 第六节 对话框函数(Dialog Box) 72 CreateDialog 72 CreateDialoglndirect 73 CreateDialoglndirectParam 74 CreateDialogParam 76 DefDlgProc 77 DialogBox 78 DialogBoxlndirect 79 DialogBoxlndirectParam 80 DialogBoxParam 81 DialogProc 82 EndDialog 83 GetDialogBaseUnits 83 GetDigCtrllD 84 GetDigltem 85 GetDlgltemlnt 85 GetDlgltemText 86 GetNextDlgGroupltem 87 GetNexTDlgTabltem 88 IsDialogMessage 88 MapDialogRect 89 MessageBox 90 MessageBoxEx 93 SendDlgltemMessage 94 SetDlgltemlnt 95 SetDlgltemText 95 MessageBoxlndirect 96 第七节 编辑控制函数(Edit Control) 97 EditWordBreakproc 97 第八节 图标函数(Icon) 98 Copylcon 98 Createlcon 99 CreatelconFromResource 100 CreatelconFromResourceEx 101 Destroylcon 102 Create_cpm_mdorect_ZIWe 102 Drawlcon 103 DrawlconEx 104 ExtractAssociatedlcon 105 Extractlcon 106 ExtractlconEx 106 Getlconlnfo 107 LookuplconldFromDirectory 108 LookuplconldFrom 109 Loadlcon 110 第九节 键盘加速器函数(Keyboard Accelerator) 110 CopyAcceleratorTable 111 CreateAcceleratorTable 111 DestroyAcceleratorTable 112 LoadAccelerators 112 TranslateAccelerator 113 第十节 键盘输入函数(Keyboard Input) 114 ActivateKeyboadLayout 114 EnableWindow 115 GetActiveWindows 116 GetAsyncKeyState 116 GetFocus 117 GetKBCodePage 118 GetKeyboardLayout 118 GetKeyboardLayoutList 118 GetKeyboardLayoutName 119 GetKeyboardState 119 GetKeyNameText 120 GetKeyState 121 IsWindowEnabled 122 keybd_event 122 LoadKeyboardLayout 123 MapVirtualKey 124 MapVlrtualKeyEx 126 OemKeyScan 126 RegisterHotKey 127 SetActiveWindow 128 SetFocus 129 SetKeyboardState 130 ToAscii 130 ToAsciiCxToAsciiCx 131 ToUnicode 132 ToUnicodeEx 133 UnloadKeyboardL 134 UnreglsterHotKey 134 VkKeyScan 135 vkKeyScanEx 136 第十一节 列表框函数(List boX) 136 DlgDirList 136 DlgDirSelectEx(2) 137 第十二节 菜单函数(Menu) 138 CheckMenuRadlol 138 CreateMenu 139 CreatePopupMenu 140 DeleteMenu 140 DestroyMenu 141 DrawMenuBar 141 EnableMenultem 142 GetMenu 143 GetMenuDefaultltem 143 GetMenultemlD 144 GetMenultemlnfo 144 GetMenultemRect 145 getSubMenu 145 GetSystemMenu 146 HlllteMenultem 147 InsertMenultem 147 IsMenu 148 LoadMenu 149 LoadMenulndirect 149 MenultemFromPo 150 RemoveMenu 150 SetMenu 151 SetMenuDefaultltem 151 SetMenultemBitm 152 SetMenultemlnfo 153 TrackPopupMenu 154 TrackPopupMenuEx 155 AppendMenu 156 CheckMenultem 159 GetMenuCheckMarkDimensions 159 GetMenuState 160 GetMenuString 161 InsertMenu 161 ModifyMenu 163 第十三节 消息和消息总队列函数(Message and Message Queue) 165 BroadcastSystemMessage 165 DispatchMessage 166 GetlnputState 167 GetMessage 167 GetMessageExtralnfo 168 GetMessagePos 168 GetMessageTime 169 GetQueueStatus 170 InSendMessage 171 InSendMessageEx 171 PeekMessage 172 PostMessage 173 PostQuitMessage 174 PostThreadMessage 175 RegisterWindowsMessage 176 ReplyMessage 176 SendAsyncProc 177 SendMessage 178 SendMessageCallback 178 SendMessageTImeout 179 SendNotifyMessage 181 SendMessageExtralnfo 181 TranslateMessage 182 WaltMessage 183 PostAppMessage 183 SetMessageQueue 183 第十四节 鼠标输入函数(Mouse Input) 183 DragDetect 183 GetCapture 184 GetDoubleCllckTime 184 GetMouseMovePoints 185 mouse_event 186 ReleaseCapture 188 SetCapture 188 SetDoubleCllckTime 189 SwapMouseButton 189 TrackMouseEvent 190 第十五节 多文档接口函数(Multiple Document Interface) 191 CreateMDIWindow 191 DefFrameProc 192 DefMDIChildProc 193 TranslateMdISysAccel 194 第十六节 资源函数(Resource) 195 BeginUpdateResource 195 CopyImage 195 EndUpdateResource 197 EnumResLangProc 197 EnumResNameProc 198 EnumResourceLanguages 199 EnumResourceNames 200 EnumResourceTypes 200 EnumResTypeProc 201 FlndResource 202 FindResourceEx 203 LoadImage 204 LoadResource 206 LockResource 207 SlzeofResource 207 UpdateResource 208 FreeResource 209 UnlockResource 209 第十七节 滚动条函数(Scroll Bar) 209 EnableScrollBar 209 GetScrolllnfo 210 ScrollDC 211 ScrollWindowEx 212 SetScrolllnfo 214 ShowScrollBar 215 GetScrollPos 215 GetScrollRange 216 ScrollWindow 217 SetScrollPos 218 SetScrollRange 219 第十八节 窗口函数(Window) 220 AdlustWindowRect 220 AdjustWindowRectEx 221 AnImateWindow 222 ArrangelconlcWindows 223 BeginDeferWindowPos 223 BromgWindowToTop 224 CascadeWindows 225 ChildWindowFromaPoint 225 ChildWindowFromaPointEx 226 CloseWindow 227 Create Window 227 CreateWindowEx 233 DeferWindowPos 235 DestroyWindow 238 EnableWindow 238 EndDeferWindowPos 239 EnumChildProc 240 EnumTreadWindows 240 EnumThreadWndProc 241 EnumWindows 241 EnumWindowsProc 242 FindWindow 243 FlndWindowEx 243 GetClientRect 244 GetDesktopWindow 244 GetForegroundWindow 245 GetLastActivePopup 245 GetNextWindow 246 GetParent 246 GetTopWindow 247 GetWindow 247 GetWindowPlacement 248 GetWindowRect 249 GetWindowText 249 IsChild 250 GetWindowTextLength 251 GetWlndowThreadprocessld 251 IsIconic 252 IsWindow 252 IsWindowUnicode 253 IsWindowVlslble 253 IsZoomed 254 MoveWindow 254 Openlcon 255 SetForegroundWindow 255 SetParent 256 SetWindowLong 256 SetWindowPlacement 259 SetWindowPos 260 SetWindowText 263 ShowOwnedPopups 263 ShowWindow 264 ShowWindowAsync 265 TileWindows 266 WindowFromPoint 267 WinMain 267 AnyPopup 269 EnumTaskWindows 269 GetSysModalWindow 269 GetWindowTask 269 SetSysModalWindow 269 第十九节 窗口类函数(Window Class) 270 GetClasslnfoEx 270 GetClassLong 270 GetClassName 271 GetWindowLong 272 RegisterClassEx 273 SetClassLong 274 SetWindowLong 275 GetClasslnfoEx 278 GetClassWord 279 GetWindowWord 279 RegisterClass 279 SetClassWord 280 SetWindowWord 281 第二十节 窗口过程函数(Window Procedure) 281 CallWindowProc 281 DefWindowProc 282 WindowProc 283 第二十一节 窗口属性函数(Window Property) 284 EnumProps 284 EnumPropsEx 284 GetProp 285 PropEnumProcEx 285 RemoveProp 286 SetProp 287

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧