mfc

MFC USB HID

风流意气都作罢 提交于 2020-01-28 03:16:34
MFC做USB HID上位机程序,背景不表,直接开始。 建立个Project; 执行Visual C++ Project|Settings,打开Link选项卡,在Category中选择Input,在Object/library modules中输入hid.lib setupapi.lib; 在应用程序一个文档内引用头文件,如: extern " C " { // Declare the C libraries used #include " hidsdi.h " // Must link in hid.lib #include < setupapi . h > // Must link in setupapi.lib } 为方便起见,a_nothing直接拷贝hidpi.h, hidsdi.h, hidusagee.h, hidsdi.lib, setupapi.lib进工程文件夹。 接下来调用API函数,完成需求。 说几个遇到的问题: 应用程序调用ReadFile()函数时,缓冲区是空的,应用程序的执行进程会停止。直到有报表,或Ctrl+Alt+Del关闭应用程序,或是从总线上移除设备。 有仨方法解决: 1. 设备继续发数据; 2. 使用重叠(overlapped)选项ReadFile读取; 3. 使用多线程执行ReadFile读取。 在此采用创建个线程读取

MFC添加图标到托盘

假如想象 提交于 2020-01-28 02:47:35
MFC窗口实现最小化到托盘 右键菜单和还原 //.h文件 void toTray();//最小化到托盘 void DeleteTray();//删除托盘图标 afx_msg LRESULT OnShowTask(WPARAM wParam,LPARAM lParam) ;//图标恢复 //.cpp文件 define WM_SHOWTASK (WM_USER +1) define IDR_SHOW 11 define IDR_OTHER 12 define IDR_EXIT 13 BEGIN_MESSAGE_MAP() ... ON_MESSAGE(WM_SHOWTASK,OnShowTask)//消息映射 END_MESSAGE_MAP() void ScheduleDlg::toTray()//最小化到托盘 { NOTIFYICONDATA nid; nid.cbSize=(DWORD)sizeof(NOTIFYICONDATA); nid.hWnd=this->m_hWnd; nid.uID=IDR_MAINFRAME; nid.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP ; nid.uCallbackMessage=WM_SHOWTASK;//自定义的消息名称 nid.hIcon=LoadIcon(AfxGetInstanceHandle()

Stucture values not staying, values changed to -858993460

混江龙づ霸主 提交于 2020-01-26 02:50:08
问题 I'm clearly doing something wrong or forgetting something. I have defined a structure in a header file with four variables. I then assign values to those variables in a function located in a different .cpp then I try and take the new values from the structure and assign to different variable in another function. Problem is, I'm able to assign values to the variables in the structure but when I try and transfer those values to other variables they become something like -858993460(this is

区分SDK、MFC、API、DLL、句柄

柔情痞子 提交于 2020-01-26 02:11:59
API是Application Programming Interface的缩写: 在Windows编程的前提下,就是特指的Windows API,是应用程序与windows系统打交道的最底层接口,平时人们常说的“用SDK写程序”就是指用Windows的API函数来写程序,API函数集由上千个API函数组成。任何一个程序,不管它是用MFC,Delphi,Visual Basic,Perl或是其它的你能想到的什么语言或是Framework所写的,都是建构在API之上的。很多情況下,这种关系是隐藏的,所以你不用跟API直接打交道。 SDK是Software Development Kit 系统软件开发工具包的缩写: 通俗地讲,Windows SDK 是帮助C程序员创建Windows应用程序的一套软件工具。它主要包括以下内容: (1)一套Windows库以及头文件。 (2)描述那些Windows函数、 来源: CSDN 作者: HelloAke 链接: https://blog.csdn.net/tiandi_5000/article/details/104059505

C++ MFC Serialization

冷暖自知 提交于 2020-01-25 21:05:59
问题 I need to serialize a vector of pointers to base class and derived class. Serialize function overloaded for both classes, so I did it succesfully like this:` CFile out; if (!out.Open(filename.c_str(), CFile::modeWrite | CFile::modeCreate)) return false; CArchive ar(&out, CArchive::store); for (auto it = container_.begin(); it != container_.end(); ++it) { (*it)->Serialize(ar); } ar.Close(); out.Close(); So the question is, how should I DEserialize it now? I have no ideas about calling correct

C++ MFC Serialization

与世无争的帅哥 提交于 2020-01-25 21:05:30
问题 I need to serialize a vector of pointers to base class and derived class. Serialize function overloaded for both classes, so I did it succesfully like this:` CFile out; if (!out.Open(filename.c_str(), CFile::modeWrite | CFile::modeCreate)) return false; CArchive ar(&out, CArchive::store); for (auto it = container_.begin(); it != container_.end(); ++it) { (*it)->Serialize(ar); } ar.Close(); out.Close(); So the question is, how should I DEserialize it now? I have no ideas about calling correct

iWebBrowser::Navigate Deadlock after a ole32.dll exception

回眸只為那壹抹淺笑 提交于 2020-01-25 20:52:11
问题 I have a question related to windows embedded browser and COM. What I am trying to do is to display some data to the user in a HTML form so I use the iwebbrowser2 control to achieve this. I have this weird deadlock or hang in my application after a call to iwebbrowser2 Navigate is made after a ole32.dll crash. This ole32 crash randomly happens in my application. There is not a usual place or time in which the exception happens. It could happen right in the beginning on the application

MFC获取电脑硬盘序列号(附源代码)

老子叫甜甜 提交于 2020-01-25 09:51:24
在新建的project里面加入一个类 即:下面一个类 GetHDSerial.cpp <code class="hljs cs has-numbering" style="font-family: 'Source Code Pro', monospace; display: block; padding: 0px; color: inherit; box-sizing: border-box;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="font-family: 宋体 !important; margin: 0px; padding: 0px; color: rgb(136, 0, 0); box-sizing: border-box;">// GetHDSerial.cpp: implementation of the CGetHDSerial

MFC : Focus rectangle of check box or radio button blackened in a Cformview

你。 提交于 2020-01-25 07:27:10
问题 I have a solution who worked fine from 3 month, versioned and not modified. Today, i run the solution, i get this : Remarque 1 : i never override "OnCtlColor" or inherite base classe (CFormview) or something like that. Remarque 2 : i don't have this problem in "Release" mode Thanks. 来源: https://stackoverflow.com/questions/59140834/mfc-focus-rectangle-of-check-box-or-radio-button-blackened-in-a-cformview

HTML table data issue in MFC application

偶尔善良 提交于 2020-01-25 04:40:05
问题 I created MFC application based on HTML that using class CDHtmlDialog for rendering of HTML, now I want to get table (row, column) data on_click . Thanks 回答1: Messaging in CDHtmlDialog is handled by DHTML Event Maps. Insert a hyperlink in html file <a href="#" id="event_id">text</a> Handle messages as follows: class CMyDHtmlDialog : public CDHtmlDialog { DECLARE_DHTML_EVENT_MAP() HRESULT on_event(IHTMLElement*); ... }; BEGIN_DHTML_EVENT_MAP(CMyDHtmlDialog) DHTML_EVENT_ONCLICK(L"event_id", on