FAQ Database Discussion Community


::PostMessage doesn't work when I am tabbed in to another program

c++,mfc
In our Program we have a Dialog from a separate dll open to display infomation. I need to close this dialog when our system timer causes the system to lock. I send information to the dll by registering a system message in both my MainFrm and EditDisplayDll SYSTEMLOCK = RegisterWindowMessage("SystemLock");...

Application logs on the command prompt from where application is being launched

c++,windows,mfc,command-prompt
I have an MFC application and launching its .exe from command prompt. What I want to achieve is that I want to show any logs from this launched application on the same command prompt. I have written this code: AttachConsole(ATTACH_PARENT_PROCESS); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), errorMessage, ((string)errorMessage).length(), NULL, NULL); FreeConsole(); But this code writes...

CInvalidArgumentException when checking class in PreTranslateMessage

c++,exception,visual-c++,mfc
The case: I'd like to make shortcuts with numpad so users can use my application fast. I implemented this in PreTranslateMessage and this worked. But the case is that I have an Edit Control where the user should enter some number. So at the time the user has focus on...

MFC application Crashes in NTDLL.dll

windows,mfc,crash,ntdll
I have an MFC based application. It keeps looking for a file after few seconds (using CreateTimerQueueTimer based timer) and perform some action. This is always crashing (for unknown reason) on XP. This application works fine on windows 7 and windows 8. But problem on XP is persistent. Below is...

How to: Copy list control (mfc) data to clipboard?

mfc,clistctrl
I've created a popup menu. What should I do next and how do I retrieve element number to retrieve info? void Cmfc_test123Dlg::OnNMRClickList1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); // TODO: Add your control notification handler code here *pResult = 0; //m_Menu.CreatePopupMenu(); POINT pt; POINT current_point; GetCursorPos(&current_point); HMENU hPopupMenu...

“The Parameter Is Incorrect” MFC exception

c++,exception-handling,mfc
This is native C++. No .NET framework involved. I am trying to figure out which exception is thrown when the CListBox gets an invalid parameter. Turns out MFC uses this exception quite a lot but I can't determine the actual exception type thrown. I have tried a lot of different...

Can I have a COM interface in a service to be called from Windows Script Host?

c++,com,mfc,jscript,wsh
My goal is to create a COM interface in my Windows local service, written with C++/MFC, whose methods could be called from a Windows Script Host JScript code running under a logged in interactive user account. For instance, if I have a test.js that can be started with credentials of...

Move Window in mfc c++ without titlebar?

html,c++,visual-studio-2013,mfc
I am using this code to move the window. But this code does not work well. When I click anywhere on windows from it will move but i just want to move windows form. When i click on specific think. For example picture. I am using MFC C++ HtmlDialog. Anyone...

How to get current operating system language?

winapi,mfc
I am newbie to mfc, and I got struck over how to get the current operating system language (Ex: If it is English operating system I must get it as English and locale can be different. For English OS locale can be Japanese vice versa). Current locale I am getting...

How to call mfc C++ function in HTML JavaScript and how to call JavaScript Function in mfc C++? [closed]

javascript,html,c++,visual-studio-2013,mfc
I search on internet 1 week regularly no solution. I found one http://www.codeproject.com/Articles/2352/JavaScript-call-from-C. But that solution is very difficult to understand. This program can call JavaScript but online. I just want to call JavaScript Internally. For example test.htm inside the project. Just 1 simple function of JavaScript and 1 simple...

MFC visual c++ LNK2019 link error

c++,mfc
I just don't understand why i can use the public variables on the class but are getting a link error when trying to use the getLicenceRefused method. I wasn't sure if the problem was because of the CString copy constructor problem I have had before so took the parameter out,...

Get notification when the application becomes active / inactive

c++,mfc,dialog
I have a dialog based MFC application and I want to get notified when the complete application becomes active or inactive. When the user switches to another application and comes back to my application I need to execute some code. How can I do this? I already tried OnActivate but...

How to use namespace System; in MFC application with VC++

c++,sql,visual-c++,mfc,namespaces
help me,am new, I want to use some features(i don't know the specific word to use) present in System namespace, but when i try to add it to my project by "using namespace System",i want this to use SQLCLIENT ,i saw below link giving answer but dont have a clue...

Wrong CListCtrl items drawing

c++,windows,user-interface,mfc,clistctrl
I have my CListCtrlEx derived from CListCtrl. This list have style LVS_REPORT, LVS_OWNERDRAWFIXED and LVS_EX_GRIDLINES. I have added possibility to change font for this list. This works fine, but there is one bad thing - if I change font and before that I have not been scrolling list, then all...

Login example MFC

login,mfc
This is a very simple task. I just want to get a username and password from the user. If the username is admin and the password is password then on clicking the ok button should call the next dialog. If the username and password is something else then a message...

CMFCTabCtrl get handle of tabs and their childs

visual-c++,mfc
I have a properly initialized object of CMFCTabCtrl in my application. I have added some tabs to it by m_oMTC.AddTab(pTab, Name, -1, FALSE); now I want to iterate over over all tabs in m_oMTC, get tabs handle and check some of it's child item. How can i do this? I...

Is it possible to change Pictue Control background color istead of Changing image?

c++,visual-c++,mfc
I am trying to change color of a Picture Control box Which I added to a Dialog box in Microsoft Visual C++ environment. I did these Procedure: In Resource file-> Dialog editor I added a Picture Control box(Type=Rectangle) I had a look at this problem and tried to keep continuing...

MFC How to notify the document is changed (and display the *)

c++,mfc
I am used to, when I change a document for instance in Microsoft Word, it gets a * near the filename and the application automatically knows I should save the document. How can I replicate this behaviour in MFC and notify my Document class of these changes, so that the...

How to find out if process created with ShellExecuteEx owns a window?

c++,mfc,shellexecute,shellexecuteex
I'm using ShellExecuteEx to run external application: SHELLEXECUTEINFO shExInfo = { 0 }; shExInfo.cbSize = sizeof(shExInfo); shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; shExInfo.hwnd = 0; shExInfo.lpVerb = L"runas"; // Operation to perform shExInfo.lpFile = windowStringContainingAppPath.c_str(); // Application to start shExInfo.lpParameters = windowStringContainingAppParameters.c_str(); // Additional parameters shExInfo.lpDirectory = 0; shExInfo.nShow = SW_SHOW; shExInfo.hInstApp =...

MFC: member variable vs resource id of control

visual-c++,mfc
I am new to vc++. I want to know which is proper and efficient way of handling controls by using member variable or resource id of controls. m_Name.SetWindowTextW(_T("xyz")); or SetDlgItemText(IDC_EDIT2,_T("xyz")); or CWnd* cwd = GetDlgItem(IDC_EDIT2); cwd->SetWindowTextW(_T("xyz")); ...

MFC tooltip does not show any text

mfc,tooltip
I've got a project on vs2008 without unicode support and there is no tooltip text showing. I've tried the same code on another project with unicode support and it works alright. What am I doing wrong? BOOL CListCtrl_ToolTip::OnToolNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { CPoint pt(GetMessagePos()); ScreenToClient(&pt); int nRow, nCol;...

Store vector in CStringArray?

c++,visual-studio-2010,visual-studio-2013,mfc
This is belong to visual studio 2013 (v120). How to convert this in visual studio 2010(v100)? struct { bool operator()(const CString &a, const CString &b) { WIN32_FIND_DATA fa{0},fb{0}; HANDLE h; h = FindFirstFile(a, &fa); if (h != INVALID_HANDLE_VALUE) FindClose(h); h = FindFirstFile(b, &fb); if (h != INVALID_HANDLE_VALUE) FindClose(h); return 1...

Which is better for MFC application hot key or Accelerator?

c++,windows,visual-c++,mfc,keyboard-shortcuts
We have MFC application which has around 10 image buttons to which we want to provide shortcut keys. Shortcuts will be customizable. I have implemented shortcuts (with no customization right now) with hotkeys using ON_WM_HOTKEY() message. After searching through Goolge I am little confuse. For example, this question is suggesting...

How to convert CString to long? VC++

visual-c++,mfc
How to convert CString to long in vc++. I have used atol but it is throwing error. long ldata = atol(str); Error no Suitable conversion from CString to const char*....

Setting and connecting pixels

mfc,gdi
I want to set pixels where the mouse click is made and connect those pixels. My code is as follows. void CChildView::OnLButtonDown(UINT nFlags,CPoint point) { CDC* pDC= GetDC(); int x[100],y[100]; POINT Pt[4]; for(int i=0;i<4;i++) { SetPixel(NULL,Pt[i].x,Pt[i].y,RGB(0,0,0)); pDC->MoveTo(Pt[i].x,Pt[i].y); pDC->LineTo(Pt[i+1].x,Pt[i+1].y); } } But I am not getting anything in the output other...

VC++: how-to convert CString to TCHAR*

visual-c++,mfc
VC++: how-to convert CString value to TCHAR*.One method is GetBuffer(..) function. Is there any other way we can convert CString to TCHAR*.

MFC ownerdraw menu size [SOLVED]

mfc,cmenu
I'm wondering how I can set the size of an ownerdraw CMenu using his own text. Looking at the documentation: void CColorMenu::MeasureItem(LPMEASUREITEMSTRUCT lpMIS) { // all items are of fixed size lpMIS->itemWidth = COLOR_BOX_WIDTH; lpMIS->itemHeight = COLOR_BOX_HEIGHT; } But using this approach I have the same size for all the...

MFC SDI application parse custom parameter

c++,mfc
I have a SDI application established in Visual Studio. I understood passing a file name to an application is fine like in the commandline: MyApp.exe "C:\a.txt". However it will not accept custom arguments or URLs. Say I cannot do MyApp.exe "SomethingILike" or MyApp.exe "www.google.com" I understand the code to process...

Converting long double to CString

c++,mfc,c-strings,long-double
I am working on C++ MFC project build in unicode settings and I usually use function _ttof to convert CString to double but i couldn't find a function for long double which use TCHAR. Thanks in advance....

How can a dialog become responsive while waiting for a call to DoModal() to return?

winapi,com,mfc,modal-dialog
A button on a dialog causes a child dialog to be created, and displayed modally. e.g: void ParentDialog::OnButton() { ChildDialog dlg; int ret = dlg.DoModal(); } The parent dialog is initially unresponsive as expected. But, the child dialog also makes COM calls to a server module, which causes the server...

MFC: CListCtrl.EnableWindow(FALSE), but still scrollable? [duplicate]

mfc
This question already has an answer here: How to disable the CListCtrl select option 1 answer I have a CListCtrl list box which I would like to toggle betwen full functionality, and being read-only (ie the user can not change the selection). The member function CListCtrl.EnableWindow(FALSE) seems designed for...

Skinning CXTPButton doesn't work in Codejock 16.4.0

c++,mfc
We have a large application using Codejock (C++, MFC, VisualStudio 2012). We use SkinFramework - the user can choose between many skins. We will soon release a new version, and we have upgraded Codejock to 16.4.0. But we noticed that the skinning of the Codejock buttons doesn't work in the...

In MFC how to access CView from CWinAppEx

c++,mfc
I do not have great expertise in MFC. I have a MFC application with the basic setup: single document application. Now In the project I have the most standard setup: one ...View class one ...Doc class and one ...WinAppEx class. These three represents the model-view-controller design principle respectively. I do...

In MFC, do inactive windows receive PreTranslateMessage events?

visual-studio-2008,mfc
I have noticed a behaviour and want to confirm that there's no simple way around it. Let's say I have a main CFrameWnd which contains several CViews, often nested several levels deep. Let's say each of them overrides PreTranslateMessage(MSG* pMsg) (don't shoot me, I inherited this code :P ). The...

Cannot access private member declared in class 'CCustomCommandLineInfo'

c++,mfc,command-line-arguments
I am trying to add a command-line interface to an existing MFC application, and found a class online at this website. I have adapted it to my needs and when I try to build I get an error that reads "error C2248: 'CCustomCommandLineInfo::CCustomCommandLineInfo' : cannot access private member declared in...

Change Text Color in MFC C++?

c++,visual-studio-2013,mfc
I want to change the color of the LVITEM? m_szList is the CListCtrl. LVITEM lvItem; lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = _T("Sandra"); m_szList.InsertItem(&lvItem); m_szList.SetTextColor(RGB(255, 78, 12)); lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 0; lvItem.pszText = _T("Roger"); m_szList.InsertItem(&lvItem); This code can change the both...

Convert wide CString to char*

c++,mfc,char
There are lots of times this question has been asked and as many answers - none of which work for me and, it seems, many others. The question is about wide CStrings and 8bit chars under MFC. We all want an answer that will work in ALL cases, not a...

Creating a custom MessageBox class for MFC

c++,visual-c++,mfc,dialog
I'm trying to create a Modeless Messagebox class in MFC 6.0. The end result should look pretty similar to this: I'm trying to add an icon with the following, but it doesn't seem to work. HICON hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ERROR)); SetIcon(hIcon, FALSE); Also, is there a way to set the...

Cannot “Go To Definition” in Visual C++ 2013

c++,visual-studio-2013,mfc,visual-c++-2013
In Visual C++ 2013 Professional, when I right-click CWinApp::Run(), an MFC function, in the afxwin.h header file and choose "Go To Definition" in the context menu, nothing comes up. The definition is also unavailable on this function's MSDN article. How can I fix the problem and find the definition? What...

CStdioFile::WriteString adding additional carriage return for line feeds?

c++,unicode,mfc
I just met the following behaviour: When using CStdioFile::WriteString, it will convert a \n to \r\n. I didn't note this behaviour in earlier versions of my code, only after I converted my project to Unicode. What am I missing? I tried this code: CStdioFile file; CFileException fileException; file.Open(TEXT("c:\\test.txt"), CFile::modeCreate |...

Syntax error when choosing multiple UINT formats on MFC

c++,mfc
I have the book Programming Windows with MFC, Second Edition, by Jeff Prosise, but in the very first example this error happens: error C2146: syntax error : missing ')' before identifier '│' In this line: dc.DrawText(_T("Hello, MFC"), -1, &rect, DT_SINGLELINE │ DT_CENTER │ DT_VCENTER); If I choose only one of...

Sort files according to creation date?

c++,visual-studio-2013,mfc
First Problem is solved. Files is perfectly arrange. for (int i = 0; i < allFiles.GetSize(); i++) { box1.AddString(allFiles[i]); } vector<file> files; vector<tstring> vec; vec.insert(vec.begin(), &allFiles[0], &allFiles[allFiles.GetSize() - 1] + 1); transform(vec.begin(), vec.end(),back_inserter(files),[](wstring const &fname) { WIN32_FIND_DATA d; HANDLE h = FindFirstFile(fname.c_str(), &d); FindClose(h); return d; } ); sort(files.begin(), files.end());...

Ignoring Listcontrol 'DELETE_ALL_ITEMS' Event when closing application

c++,mfc,event-handling,listcontrol
I have a MFC ListControl in my application. I have an event that occurs when "all items in the view were deleted". The event throws an error message and then closes the program. My problem is that the event also gets called if the X(close) button is clicked. Here is...

MFC click and move/drag dialog window

c++,flash,mfc,dialog
I am currently working on finishing some code handed off to me. It was written in MFC in Visual Studio 2005 years ago, was put on hold, and now is brought to me. While I know C++, I have spent the last ~2 months studying the code and learning MFC...

CDateTimeCtrl editing short year format

c++,mfc
If the format of the CDateTimeCtrl is set to "dd.MM.yy", the date-control shows correctly at runtime the date in the format "05.05.15" But if the user places the cursor into the year-section of the control, the year switches from "15" to "2015" By leaving the year-section (for example placing the...

Relationship between AFX_WM_DRAW2D and WM_PAINT in MFC Application

c++,graphics,mfc,directx,direct2d
What is the relationship between the two messages in the subject? When exactly the AFX_WM_DRAW2D is passed to application queue. I am asking because I have encountered the strangest recursive call of AFX_WM_DRAW2D handler. Whenever I am trying to paint something inside the AFX_WM_DRAW2Din compatibe render target the handler is...

Is there any way to add an object other than CString to a CComboBox in MFC?

c++,mfc,override,control,ccombobox
I am trying to add an object that has a member variable CString to a CCombobox. I cannot just add the string because I am trying to interface with a tool that requires me to have another member variable other than just a string as a list item in the...

Populating a List Control with the sorted contents of an `std::multimap`?

c++,winapi,stl,mfc,clistctrl
As a follow-up to this question, I need a way to access my data by index. But the data needs to be sorted by timestamp, contain a filepath as a value, and be displayed in real-time as new elements are discovered. Considering that multiple files/folders could potentially contain an identical...

MFC CEdit character delete not working

mfc,cedit
I stumbled upon a strange problem today on one of my client's Windows XP SP 3: deleting with BACKSPACE or DELETE buttons a text from a CEdit won't work. To be more accurate, i place the cursor at the end of the text, and hitting the BACKSPACE button will result...

How to sync a Progress Control with a set of data which is loading in a Dialog Box in Visual C++

c++,visual-studio-2012,visual-c++,mfc
I'm trying to add a progress control in my dialogs, that will step upon every iteration of a loop until completion. I've never played around with progress controls before, so I'm totally clueless as to where I should start. I've added a progress control resource view into my dialog, but...

MFC read file and display it as HEX (hexdump)

mfc,hexdump
I need to read binary file and display bytes at certain offset so i can change that bytes and then save an updated file. I don't really understand how can i achieve that. I'm using MFC/VS 2008 So, i'am opening file using WinApi and getting its content to BYTE buffer....

How to create a single process but multithreads MFC GUI application with MPI?

c++,multithreading,mfc,mpi
All I need is just to write a simple MFC Windows application using MSMPI, but I don't want to launch multiple processes as my GUI application may need some user interaction before the multi-threading part. For instance, I'd like to create 2 threads after click a 'Run' button. I have...

Change Control's Value by a Function in MFC?

c++,mfc
I Set an int Variable for IDC_EDIT1 Control. now i Want Change it With a Function, But when clicking on Button, Show an Error! void test() { CthDlg d; d.m_text1 = 5; d.UpdateData(FALSE); } void CthDlg::OnBnClickedOk() { // TODO: Add your control notification handler code here // pThread = AfxBeginThread(ThreadFunction,...

How to make mouse function run continuously in the background?

c++,multithreading,mfc
Few days ago, I asked a question and got answer. However I could not proceed any more because of some problems. (=> How to implement mouse_event() to work continuously in MFC?) (I am trying to make a MFC program which works like a mouse by using Myo.) First, I made...

reset mdi child view position

mfc,mdi,mdichild
I have a MDI application using CMAXMultiDocTemplate for child doc/view. Every time calling the OpenDocumentFile() will create and show a new child view. The first window position starts from X=0 and Y=0 and then every followed newly created child window has added an offset of X=29 and Y=29 by default...

How would you open a Dialog when an edit box is selected? MFC 2005

mfc,dialog,keyboard,editbox
I would like to be able to create an onscreen keyboard to popup whenever an edit field is selected. I am using MFC Visual studio 2005 (C++ based). Below is my code so far: void CTestHarnessDlg::OnEnChangeEdit3() { CKeyboard Dlg; Dlg.DoModal(); } When I run the Dialog box and click on...

Why is there a memory leak on SHGetFolderPath()? (C++)

c++,memory-leaks,mfc,intel-inspector
I am runing Intel Inspector for finding memory leaks in an application. Now, the case is this: assume there is a function called MyGetPath() which does the following: _TCHAR szFolderPath[520] =_T(""); SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES,NULL,NULL,szFolderPath); return _T("MemLeak"); When I run the Intel Inspector it reports a leak by 40 bytes, and the allocation...

Should Resource IDs be unique in my shared MFC DLLs

visual-c++,mfc
Example: The first MFC DLL has a menu ID_MENU_FOO with ID value 4711 in resource.h. The second MFC DLL also has another menu ID_MENU_BAR with the same ID value 4711. The Application (exe) uses both DLLs and calls LoadMenu. If I want to verify the desired menu to be loaded,...

Buttons not getting replaced in CMFCToolbar at runtime

visual-c++,mfc,mfc-feature-pack
I am using CMFCToolbar in a CMFCDesktopAlertDialog which is contained inside a CMFCDesktopAlertWnd. Initially I create the window and insert 3 buttons. Then on some action, I want to change those buttons to 2 or 3 different buttons. I tried using CMFCToolbar::RemoveAllButtons() & then InsertButton(). However, it did not work....

Using GetHttpConnection in MFC

c++,mfc,jersey,wininet,winhttp
I have a rest Server written in java and I am trying to call a GET method from an MFC client. The server URL is http://localhost:8080/com.test.simpleServlet/api/customers and this returns me the proper value when I run through the crome postman plugin. I have implemented Java Restful WebService as the Server,...

I have integrated CLIPS with VC++(MFC), why there are some function does't execute,such as “strcmp”

c++,mfc,integration,clips
I used the CLIPS6.30 version, and the way that I embeded the CLIPS into VC++ was just like the wrappedDLLExample shown in "advance.doc" (using CLIPSWind32.lib and CLIPSWin32CPP.lib). When I write a class myCLIPSCPPRouter, I need to compare the logicalNames.But the function "strcmp" doesn't work. The code line was skipped. int...

variable global const “macros” in C++ and optimal design patterns

c++,design-patterns,mfc,const,global
I inherited some 10 year old code I have to complete. The code is in MFC (C++). There's a .h file where the custom data structures are written and some const variables are in there as Globals. Some of these are used for MS Office file extensions, of type CString,...

Visual Studio 2013 tries to load localized afxres.rc from older version

visual-studio-2013,mfc
We have recently upgraded an MFC solution from Visual Studio 2005 to Visual Studio 2013 (Update 4), at last. I think the solution originates in Visual Studio 6 and was upgraded to VS2003, then VS2005. It is a Multibyte (i.e. non Unicode) solution. We haven't had many problems, so far....

Multiple Key Press handling in mfc

visual-c++,mfc
How to handle multiple key press in MFC. I have tried for few key combinations.But How to generalize for all key combination. BOOL Test::PreTranslateMessage(MSG* pMsg){ if(pMsg->message==WM_KEYDOWN ) { if(pMsg->wParam == 'C' || pMsg->wParam == 'V') { if(GetKeyState(VK_CONTROL) < 0){ } } } } ...

How to convert cv::Mat to MFC CBitmap

c++,opencv,mfc
how can I convert an OpenCV image to an Microsoft Foundation Classes (MFC) CBitmap object? I tried the following, which failed, cv::Mat tmp; (Load opencv image ...) cv::Size size = tmp.size(); CBitmap bitmap; // 3 colors (RGB), 24bits (8bits*3channels) if (!bitmap.CreateBitmap(128, 128, 1, 24, (void *)tmp.data)) { TRACE0("Failed to create...

Press Button automatically?

c++,visual-studio-2013,mfc
I press button one time. And after that i want press button automatically. I try this code. But not working. Button variable name is ok. VOID CALLBACK timerCallback(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { CkTimerDlg *box = (CkTimerDlg *)AfxGetMainWnd(); CString test = _T("Button Not Clicked"); box->testBox1.AddString(test); HWND hwdButton...

Background color for controls in MFC C++ is unable to set

c++,mfc
I am trying to set the text color using SetTextColor and background color using SetBkColor in on_wm_ctlcoloredit function. But whenever I try to set only text color, the output actually paints the background as black where the text is not present and white where text is present. I am expecting...

CMenu border color on MFC [SOLVED]

mfc,cmenu,ondrawitem
I've a class that inherit from CMenu Owner draw menu using this class the Menu appears correctly but, for example, when you open the menu FILE you will see the border and the separator of the standard menu color How I can paint also this part of the desired color?...

Zoom Bitmap Image from center in mfc

visual-c++,mfc
I am new to MFC. How to zoom Bitmap image from center. In my code image is zooming from top left corner. But image should zoom from center in scrollbar.. void CRightUp::ImageDraw(int sHeight,int sWidth){ CDC *screenDC = GetDC(); CDC mDC; mDC.CreateCompatibleDC(screenDC); CBitmap bitmap; bitmap.CreateCompatibleBitmap(screenDC, sWidth, sHeight); CBitmap *pob = mDC.SelectObject(&bitmap);...

Creating a popup CMenu without a checkbox

c++,visual-studio-2010,mfc,windows-forms-designer,cmenu
I am creating a CMenu in Visual Studio 2010, MFC. I have a working CMenu that appears when a user right-clicks on a dialog. I can't seem to find a way to create menu selection without a spot for a checkbox. In Visual Studio's designer, my menu looks like this:...

how to correctly send CMFCMenuButton selected ID to the message map?

c++,menu,mfc,dialog
firstly let me describe what I have: scenario: CMFCMenuButton, loaded with a CMenu, in a dialog test: click on an item of the menuresult: the message map will get the ID of the CMFCMenuButton and not the ID of the menu how to get the actual menu ID clicked: use...

CMFCColorButton does not appear in MFC class wizard dropdown

c++,visual-studio-2013,mfc
I was trying to create a CMFColorButton derived class with class wizard. However, in Visual Studio 2013 the CMFCColorButton parent class does not appear in the "Base Class" dropdown in the class wizard. What could be wrong?...

MFC: How to fix row and column repetition in CListctrl

visual-c++,mfc
I am new to vc++.How to fix row and column repetition in CListctrl in MFC. int nItem = 0; m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 100); m_list.InsertColumn(1, _T("Area km\262"), LVCFMT_RIGHT, 80); m_list.InsertColumn(2, _T("Population"), LVCFMT_RIGHT, 100); m_list.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); ModifyStyle(0, LVS_REPORT); nItem = m_list.InsertItem(0, _T("Libya"), 8); m_list.SetItemText(nItem, 1, _T("1,759,540")); m_list.SetItemText(nItem, 2, _T("5,499,074")); nItem...

How to handle Key press ctrl+shift+A in sdi mfc

visual-c++,mfc
I am new to vc++.How to handle Key press ctrl+shift+A in sdi mfc. For ctrl + A code is working fine. case _T('A'): if(GetKeyState(VK_CONTROL) & 0x8000){ MessageBox(_T("Key Ctrl+A is pressed")); } else if((GetKeyState(VK_CONTROL) & 0x8000)&&(GetKeyState(VK_SHIFT) & 0x8000)){ MessageBox(_T("Key Ctrl+Shift+A is pressed")); } break; ...

Win32, MFC: Ending threads

c++,multithreading,winapi,mfc
I have a DLL which has a CWinThread based class called CWork. I create it using AfxBeginThread. In this class I defined a procedure that will loop infinetly and perform a certain task. This procedure will be used as a thread by itself. I create it also using AfxBeginThread. Now,...

How To Get Window handles In Mozilla Firefox

winapi,mfc,ui-automation
How to get handles of all the child windows in Mozilla firefox. Spy++ is showing only one class and window caption for all the windows. I tried using GetWindow and FindWindowEx but got nothing. I want to read URL from mozilla firefox.

JQuery ui in not working with mfc htmldialog?

javascript,c++,jquery-ui,visual-studio-2013,mfc
This code perfect work with asp.net c#. I am using this code but not working with mfc htmldialog. Error is Object does't support property or method tabs. <HEAD> <title></title> <link href="jquery-ui-1.8.8/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" /> <script src="jquery-ui-1.8.8/jquery-1.4.4.js" type="text/javascript"></script> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="jquery-ui-1.8.8/ui/jquery.ui.widget.js"...

Dynamic Memory Deletion in vc++

visual-c++,mfc
I am using _aligned_malloc in my code. But it is throwing error error as shown in image. CString sBuffer = _T("Hello"); TCHAR* pBuffer; pBuffer = (TCHAR *)_aligned_malloc(1024, 16); if (pBuffer == NULL) { ...............Error .. msg } pBuffer = sBuffer.GetBuffer(sBuffer.GetLength()); .................................................. ......................................................... sBuffer.ReleaseBuffer(sBuffer.GetLength()); if (pBuffer != NULL) { _aligned_free(pBuffer); }...

Handling multiple WM_USER messages (or achieving the same result)

c++,mfc,windows-messages
I have a WidgetController class that controls multiple widgets (motors as it turns out, but it could be practically anything). It has a companion UI class WidgetControllerUI to do UI things representing the multiple widgets. I would like to send messages such as WM_USER + 1000 + N from the...

UCHAR * to CString conversion and CString to UCHAR * to conversion in vc++

visual-c++,mfc
I am new to vc++. How to convert UCHAR * value to CStringand CString to UCHAR * CString str; UCHAR * pBuffer; ......Memmory allocation.. str.format(_T("%d"),pBuffer); But its not working. Second data may be string or int so how to do conversion in proper way....

How to zoom in/out an image on clicking zoom in/out button in SDI?

visual-c++,mfc
I am new to VC++. How to zoom in/out an image on clicking zoom in/out button in SDI.

MFC EndDialog crashes when modal dialog does not have focus

c++,mfc
I am closing a modal dialog after I end a task, inside a separate thread from where I created a modal dialog: void CmodguiApp::_notify_task_end() { processingDialog->EndDialog(0); } This works fine if my application has focus (therefore the modal dialog has focus). But this causes the application to crash if I...

How to limit the number of MDI tab groups

c++,mfc
I have created a MDI application with tabbed group. Each time I drag and drop one tab from tab bar to view, it will create a new tab group and divide view according to the number of tab groups. But I want to allow my application to create only two...

Create a control dynamically in an MFC application

c++,visual-studio-2013,mfc,cdialog
According to this link from Microsoft, it should be possible to define a CButton and specify its parent window (CDialog) without having the CButton as a member of the Dialog, but I couldn't do it. So if myButton is a member of a CDialog-derived (myCDialog) class, the following code works:...

InternetGetCookie error 259 ERROR_NO_MORE_ITMES c++

c++,http,cookies,mfc
I've to check/get cookies of one site because i cannot, i've always got error 259 ERROR_NO_MORE_ITEMS with InternetGetCookies function (exemple: check/get cookie of "http://www.google.fr" url doesn't run, i have Error 259. wchar_t wchCookiesData[4096]; unsigned long ulCookiesDataLength = 0; bool bRet = InternetGetCookie(L"http://www.google.fr", NULL, out_pwchCookiesData, &ulCookiesDataLength ); That is my code...

Retrieving keyboard interrupt result in mfc

c++,mfc,keyboard,interrupt-handling,pagedown
I have CListCtrl and I'm trying to handle some keyboard buttons such as page-up / page-down etc. I'm using OnLvnKeydown handler. My problem is retrieving the item's index AFTER the keyboard interrupt. For instance, if item 1 is marked and I press page-down I want to show the details of...

Why are images not appearing on subitems in mfc CListView/CListCtrl?

c++,mfc,clistctrl
I've created a very simple view derived from CListView, and I want to be able to show images on each column of my CListView. To do that I know that I have to use LVS_EX_SUBITEMIMAGES and use SetItem to set the Image in the sub item, simple as that, but...

Convert CWnd* to myControl*

c++,casting,mfc,control,cwnd
I am trying to convert a CWnd* pointer to a custom control pointer. The custom control just extends CEdit. Below is what I have. pWnd was passed in. it is a CWnd*. calEdit* test = (calEdit*)pWnd->GetDlgItem(pWnd->GetDlgCtrlID()); When I try to debug and see what the value of test is, none...

What are the consequences of not calling GdiplusShutdown before exiting an application?

c++,mfc,gdi+
I'm currently working on a legacy MFC application and I noticed that there was a missing call to GdiplusShutdown() before exiting the application. The documentation clearly states that each GdiplusStartup call must be paired by a call to GdiplusShutdown(). What happens if this function is not called ? Object leak,...

Convert C# String to MFC CString in C# project?

c#,c++,string,mfc,c-strings
I am developing a client in C#. The server was developed by other who used C++ MFC, so I can´t change it. The server can only accept string data as CString (UTF8). Note: before I ask this question I have searched and read many threads, eg. thread1, thread2, thread3, etc....

Create ini file in current directory in MFC

c++,winapi,mfc
The problem is I don't want to write any details into the ini file. I just want to create an ini file in the current directory or in another e.g. in the debug folder where the main .exe is. //CIniWriter iniWriter("Logger.ini"); void CIniWriter::Init(char* szFileName) { memset(m_szFileName, 0x00, 255); memcpy(m_szFileName, szFileName,...

CMFCTabCtrl color customising

colors,tabs,mfc,color-scheme
Is there the way to change the line and background colors of CMFCBaseTabCtrl? I can change tabs color via SetTabBkColor(...) or SetAutoColors(...) but control's header and lines remain grey. SetSysColors(...) is not an option because it changes colors globally for entire OS. Basically we need to apply some lite/dark color...

About class CRect & Rect, Width = right - left

c++,image-processing,mfc,rect
It is a problem about C++ and mfc. For example, left = 3, right = 8. Doesn't it mean there are 6 pixel from left to right? Why the width = right - left? If I know a rect which represents the image rect, when I allocate memory for the...

How to enable user to re-entry(or) reuse the same dialog in MFC

visual-c++,mfc,dialog
I'm currently doing a FTP download using MFC. Is a very simple program which takes 2 inputs from user and click a download button in order to download from server. Everything is fine and im able to download it from. But i realized this program can only be executed once....

std::reverse on MFC CArray

c++,stl,mfc
I have an array of points like this: CArray<CPoint,CPoint> points; And I need to reverse the order of the points. I've tried this method: std::reverse( &points[0], &points[0] + points.GetSize() ); And it works. Then I've tried this other method: std::reverse( &points[0], &points[points.GetUpperBound()] ); But it doesn't work: the last item...

MFC Custom Keyboard DLL Accessed from Application Dialog Box

dll,mfc,keyboard
The overall goal is to be able to access a pop-up keyboard through an application that I am making in MFC. I have created a dialog box with an empty text field. I would like to be able to click the empty field and have an onscreen keyboard to enter...

How to save layout settings of MFC application?

c++,windows,mfc
I understand there are functions that can easily write windows registry, however I found out that in new MFC project created with wizard, some information (like split bar position, visibility of controls) gets stored automatically (or at least I found no CWinApp::Write* calls in the project). Since I have also...

Getting Desktop Resolution in MFC C++

c++,mfc,stringstream,getsystemmetrics
I have inherited some partially developed 10 year old code that was written in MFC C++. I've been tasked with updating and finishing the app. In the CDialogChild class, it looks like this in the .h file: private: static const int m_iDefaultDesktopSizeX = 1024; static const int m_iDefaultDesktopSizeY = 740;...

I'd like to know where to declare variables, according to philosophy of programmers

c++,mfc
I am a student studying MFC. I want to declare ChildView region variables. Where do I have to declare variables? header file? or cpp file? I think both work well. But I want to know general style. Please let me know which are desirable. // ChildView.h : interface of the...

Can a dialog intercept drag'n'drop messages passed to its controls?

winapi,mfc,drag-and-drop
If a dialog registers some of its controls as drop-targets, will drag'n'drop messages intended for those controls pass through the dialog's message processing in a way that the dialog can register a message handler to be notified/intercept those messages? In a similar fashion to this question, I want to catch...