Click here to Skip to main content
15,897,704 members
Everything / Programming Languages / VC++

VC++

VC++

Great Reads

by Naveen
How local static variable is implemented in VC++
by Paolo Messina
Class library to make development of resizable windows a easier for the MFC developer and pleasant for the user
by Marc Richarme
Could be used to create a Visual C++ like search combo for CHtmlViews... With the update, you can highlight all matching words!
by The Ænema
This article brings you a very detailed but easy to learn experience on creating your own x64 PE packer/protector using only VC++!

Latest Articles

by Paolo Messina
Class library to make development of resizable windows a easier for the MFC developer and pleasant for the user
by David 'dex' Schwartz
Old style printf format strings ported to an ostream shim class
by The Ænema
This article brings you a very detailed but easy to learn experience on creating your own x64 PE packer/protector using only VC++!
by The Ænema
Learn how to convert any code to a stable shellcode using Visual Studio 2019 and VC++ in easy steps!

All Articles

Sort by Title

VC++ 

8 Nov 2020 by rajesh482
I've implimented a ATL single thread apartment based project . class ATL_NO_VTABLE CMySrv : public CComObjectRootEx, public CComCoClass, public IMySrv In the method, I'm creating multiple worker...
5 Jul 2017 by joyjhonson
Hi all, I am including below files in my project. exec\msvc140_64\include\rw\config\rwconfig_tls.h definition of rwconfig_tls.h header file #include "rwconfig.h" #if defined(_RWCONFIG_12d) #include "rwc_tls_12d.h" #elif defined(_RWCONFIG_15d) #include "rwc_tls_15d.h" #else #error "No...
5 Jul 2017 by KarstenK
Yes: Read the error message and analyze the code. #if defined(_RWCONFIG_12d)// found" //
1 Feb 2016 by Member 11978923
When I use logarithmic coordinates in NTGraph,coordinate axes and grid are wrong.How to fix it?Thank you!(No code,just setting)
2 Feb 2016 by Dave Kreskowiak
"CodeProject" did not write the control. The person who wrote the article you got the control from wrote the control.There is a forum at the bottom of the article your got it from. Post your question there and the author should support the code he wrote.
23 Apr 2017 by Member 13089825
How to implements to access only alphabetic characters in vc++ mfc What I have tried: BOOL CFilterGroup::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_CHAR) { if ((pMsg->wParam >= '\x41' && pMsg->wParam
23 Apr 2017 by Jochen Arndt
You have to reverse the check and the return value. See CWnd::PreTranslateMessage[^]: Quote: Nonzero if the message was translated and should not be dispatched; 0 if the message was not translated and should be dispatched. You have to return TRUE if a message should be filtered out. To check...
23 Apr 2017 by Richard MacCutchan
Your test looks wrong; surely it should return TRUE to indicate an alphabetic character. Also, why use hex rather than actual characters? So ... if ((pMsg->wParam >= 'A' && pMsg->wParam wParam >= 'a' && pMsg->wParam
21 Apr 2021 by Remspec
I am in the process of trying to upgrade a VC++ 6.0 project to the latest version and am running into an issue. The program starts up fine but in the process of creating two child windows within the main view it crashes with an access violation....
22 Jun 2017 by Coder969
We are migrating our project from vs2005 to vs2015 . In one of the project we are using Ad1.lib .When I build that project in vs2015 getting the error saying Ad1.lib not found . In vs2005 this lib was present in " C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Lib " but I...
22 Jun 2017 by RickZeeland
You can try to copy the Ad1.lib to your project and include it, if you still have it. Then under the file properties set "Copy to working directory" to always. If that fails, try this: visual studio - VS2005 and Windows SDK 7.1 - Stack Overflow[ ]
22 Nov 2000 by Marc Richarme
Could be used to create a Visual C++ like search combo for CHtmlViews... With the update, you can highlight all matching words!
12 Apr 2017 by Member 13089825
can we allign some text from left side and some text from right side to the statusbar in vc++ What I have tried: i have added the spaces from left side after spaces i have added another text but when big text coming space is not showing equal for all the time
12 Apr 2017 by Richard MacCutchan
You have to get the actual width of the status bar window and then adjust your text to fit. See CWnd::GetWindowRect[^] and CDC::GetTextExtent (MFC)[^].
12 Apr 2017 by Jochen Arndt
You have two options where both requires deriving a class from the CStatusBar Class[^] or the CMFCStatusBar Class[^]. Change the type of m_wndStatusBar in your main frame window class header file to the derived class and include the header file of the derived class. If necessary create and...
17 Nov 2017 by Member 12208944
Visual C++ 6.0 Dialog based application receiving data from one instrument-1 through Ethernet code is working.Now in the same code I am changing generating some signal from instrument-2 sending to instrument-1 with signal passing cable data is receiving from instrument-1 through Ethernet.Here...
6 Mar 2017 by Premnath Mali
I wanted to call a function Recurse(LPCTSTR pstr) to scan files and at the same time wanted to do another task but when I'm clicking on Resume Button I have to wait Until whole scanning finished.what should I do...What I have tried:void...
6 Mar 2017 by Jochen Arndt
You have to create a worker thread that performs the operation in the background.But MFC is not thread safe so that you have to implement some kind of signaling like sending user defined Windows messages if you want to update GUI elements from the thread. You might also need to track the...
7 Apr 2017 by abhilashmfc
Hi all, I was migrating our project from 2010 to 2015, but I was facing linking issue saying that atlsd.lib was not able to open. The installation folder for VS2015 "C:\LegacyApp\VisualStudio2015\VC\atlmfc\lib" doesn't have debug version of this lib, but it has release version "atls.lib" I have...
7 Apr 2017 by Jochen Arndt
This debug library has been removed with VS 2013 Visual C++ change history 2003 - 2015[^]: Atlsd.lib, atlsn.lib, and atlsnd.lib are removed. Atls.lib no longer has character-set dependencies or code that's specific for debug/release. Because it works the same for Unicode/ANSI and debug/release,...
25 Sep 2022 by David 'dex' Schwartz
Old style printf format strings ported to an ostream shim class
19 Dec 2017 by Member 13089825
could you please help me to select the files from inside folder. when i tried its selection only folder names not files not listing What I have tried: BROWSEINFO bi; ZeroMemory(&bi, sizeof(bi)); TCHAR szDisplayName[MAX_PATH] = { 0 }; bi.hwndOwner = NULL; bi.pidlRoot =...
19 Dec 2017 by Jochen Arndt
You must show a file selction dialog and not a folder selection dialog as the function name SHBrowseForFolder tells you. Windows provides common dialogs including a file dialog (see Common Dialogs (Windows)[^]). With MFC you can also use the CFileDialog Class[^] which encapsulates the common...
7 Oct 2021 by woody braun
If You change bi.ulFlags = BIF_RETURNONLYFSDIRS; to bi.ulFlags = BIF_BROWSEINCLUDEFILES; you will have also the files in the browsing list!
30 Dec 2016 by MarshalS
I have a c++ code to display all the process with the session ID . but this code is not working perfectly in some Windows xp machines , because of ProcessIdToSessionId() methods minimum support is Windows Vista. Anyone have suggestion about how to do it for Windows XP. Here is my codeWhat I...
30 Dec 2016 by Jochen Arndt
Quote:because of ProcessIdToSessionId() methods minimum support is Windows VistaThat is from the actual MSDN documentation. Because Windows XP is not supported anymore, it is removed from the documentation.If you want to support XP (or even older Windows versions) you should use an older SDK...
1 Jun 2020 by Member 13261094
Hi , I am new to c++, could you please help me with below code. CObject *m_pRetObj1; CObject *m_pRetObj2; m_pRetObj2 = m_pRetObj1; Requirement is m_pRetObj2 , should have all values of m_pRetObj1 in new address space. as of now, address...
31 May 2020 by OriginalGriff
If you want different objects, then you need to create two different instances, and copy the data over. At the moment, you don't create any instances, so your code won't work anyway: the pointer will either contain null values - and your app...
1 Jun 2020 by KarstenK
In a nutshell: your variables are ONLY pointer and NOT real objects. Imagine them as address values - and both addressing the same object in your code. In your case a so called deep copy may help, when your CObject class has implemented it. Use...
17 Apr 2017 by Member 13089825
need to implement a functionality while changing window size (ez:dragging or minimizing or maximizing) need to call function with updated window width(). could you please help me if any function is there to call depends on window size changes. vc++ mfc What I have tried: currently getting...
17 Apr 2017 by Richard MacCutchan
You need to respond to the WM_SIZE[^] and WM_MOVE[^] messages.
17 Apr 2017 by Jochen Arndt
Override CWnd::OnSize[^] of your window class.
28 Jul 2018 by Member 12533122
i want termite source code in c++ instead of c#. please anyone help me in this matter. What I have tried: as i am using serial communication in vc++ i am getting 37 byte packet in 3 second and that is too much. so i need help in this.
28 Jul 2018 by OriginalGriff
No. Partly, we aren't here to do your job for you, but mostly we aren't a code translation service and didn't write Termite anyway. And if you think that 37 bytes in three seconds is "too much" then you really need to brush up on serial coms...
5 Apr 2021 by tdc_india
yes, we want to upgrade it to build in VS2019. What I have tried: We are yet to try anything. Need expert opinion.
5 Apr 2021 by Richard MacCutchan
You do not run projects in the Visual Studio IDE, you run them in Windows. And the way to check whether it runs successfully is to try it. If you want to upgrade it to build in VS2019 that is a different issue. Some of the older project files...
11 Jul 2019 by Member 14499788
I have written the programmm, but my code is not functioning.If anyone could provide a working example, it would be very kind. Cheers! What I have tried: I have tried doing with Socket class but ist not functioning and it doesnt shows me any error. So i find it dfficult to understand weher...
11 Jul 2019 by Richard MacCutchan
Google for "C++ sockets" and you will find many samples.
11 Jan 2016 by Vijay533
Is there any way can i get the path based on cursor position, what i mean suppose i open 3 folders like D:\vijay\temp, c:\system\data, E:\data\directory, if i move the cursor from my application to any of these folders, can i get the directory path?, based on cursor position. My application...
12 Jan 2016 by KarstenK
Looks like you have a similar question as I answered here.What have coded so far?
27 Sep 2018 by Member 13999828
've used the Visual Studio project wizards to create some basic GUI apps with VC++. When debugging, I've noticed the native MFC code to be riddled with syntax such as this: derivedClass::Method() { baseClass::Method(); } For exmaple, I created a simple Windows app titled MFCApp. ...
27 Sep 2018 by KarstenK
This are the calls of the base class implementation of the methods. Dont ferget that these code is in the class instance code and not outside. In your link it is different sample code. Outside of the class and the second is a static function. Static means global unique, but in the name space of...
27 Sep 2018 by Member 13999828
Thanks for your reply. Then please tell me why the following does not work ? class base { public: virtual void OddFunction() const; }; class Derived: public base { public: virtual void OddFunction() const; }; Derived OddFunction() { base::OddFunction(); } int main() { Derived d; ...
14 Feb 2016 by Member 11825032
I need to create buttons with different shapes like ellipse, triangle. Is it possible to create buttons with different shapes in C++ on MFC dialog using visual studio 2012.What I have tried:I need to create buttons with different shapes like ellipse, triangle. Is it possible to create...
14 Feb 2016 by Richard MacCutchan
Yes it is possible, but you need to do all the work of drawing the button yourself. See owner draw button - Google Search[^].
14 Feb 2016 by CPallini
Let's see if we have one or two articles on such a topic, here at CodeProject[^].
13 Feb 2017 by Premnath Mali
I have student structure and I wanted to store it in list control how can we do this?see in coding lstStudent is the list objectWhat I have tried:struct Student { char sname[25]; char id[5]; char sclass[10];};void CStudent::SaveData(){ Student s1; CString...
13 Feb 2017 by Richard MacCutchan
You probably mean CListView Class[^], although you have to add items manually from the structure for each column. Or you could switch to C# which provides data binding.
13 Feb 2017 by Jochen Arndt
You have to add corresponding columns to your list control which must be in report mode (LVS_REPORT style, usually defined in the resource file). Do this within the initialisation function of the parent window (e.g. OnInitDialog with dialog windows):m_lstStudent.InsertColumn(0,...
19 Sep 2017 by Member 13089825
i am storing values in resgistery while closing application and while relaunching application im getting values from registery (values coming coming correctly)and those values i want update in in the CREATESTRUCT but values not updating in CREATESTRUCT What I have tried: LPTSTR p =...
19 Sep 2017 by Jochen Arndt
The common place to restore the window size is OnCreate or ShowWindow (when called the first time) instead of PreCreateWindow. That can be used to modify the window class or style but window size and position may be changed by other functions before the window is shown the first time or even...
25 Feb 2016 by Member 11937050
my project is in unicode mode and iam able to read unicode files by using Carchive , but same archive when iam reading ANSI files in unicode .its reading some junk values.can u tell me how to read by using CFile ?What I have tried:CFile fileIn(_T("D:\\test.txt"),...
25 Feb 2016 by Jochen Arndt
CArchive is not intended to read common text files. It is used to save and store a binary representation of the data used by your application (commonly the data hold by your CDocument class). If you use the CArchive string functions, they will use Unicode strings with Unicode builds and...
6 May 2020 by Coder969
We have a com dll from third party and using that com dll from the vb script. We want to remove the third party dll and write our own dll with same name and object so that we dont need to change anything in our scripting code. I created the new...
12 Mar 2017 by Anoha
iam using list control in mfc . pls help to change the color of list control of view record?
9 Mar 2017 by Jochen Arndt
To set the color for all items use SetTextColor and SetBkColor [EDIT], and SetTextBkColor[/EDIT].If you want to set the colour for individual items, you have to handle the NM_CUSTOMDRAW notification: Neat Stuff to Do in List Controls Using Custom Draw[^]
17 Dec 2020 by adityarao31
m_pReportAPI.CreateInstance("M...
17 Dec 2020 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
17 Dec 2020 by adityarao31
MAXExact.ReportAPI is GUID.And I think some guidance I will able to get from COM programmer
4 Apr 2019 by Gerry Schmitz
Yes; it's called "Movie Maker".
26 Sep 2019 by Member 14373667
#ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // 1 TYPELIB "TellerCaptureX.tlb" ///////////////////////////////////////////////////////////////////////////// #endif // not...
26 Sep 2019 by CPallini
A quick and dirty search result: TIP: Adding a typelibrary as a resource to a project[^].
26 Sep 2019 by KarstenK
Read about the documentation yourself but you need to provide 2 different versions of the tlb for 32 and 64 bit platform. One possible solution to guard these tlbs with some x64 macros. Like #ifdef _X64_ // or your x64 define 1 TYPELIB "TellerCaptureX64.tlb" #else 1 TYPELIB...
23 Mar 2016 by Member 11937050
Iam having issue with the following line of code its crashing in delete. could you please the code and let me know the issuemap::iterator it = m_Map.begin(); while ( it != m_Map.end() ) { CTest*pDTerst(it->second); if ( pDTerst) delete pDTerst; /crashing some...
23 Mar 2016 by Jochen Arndt
You are creating a CTest instance on the stack and trying to delete it aftwerwards. That will of course crash because you can only delete objects that has been allocated on the heap using new.So you would probably want to do something like this (depending on the type of the second std::pair...
11 Jul 2017 by Member 13155774
hello ; I want to use WinCC flexible vc++ to creat a excel file and write something inside. i have tried lots but cant find any permenent solution. i am using visual studio 2008 and wince project . plss any one suggest me how to create excel file in wince and any proper wince excel application....
11 Jul 2017 by Richard MacCutchan
Microsoft.Office.Interop.Excel namespace ()[^]
30 Aug 2021 by Aashish_stellar
Hello, I am working on .xlsx file on windows in VC++ MFC and trying to create table in its worksheets. I am using XLS2007::ListObjects::add function for creating table but function fails every time. Please have a look what I am doing: What I...
30 Aug 2021 by Maciej Los
As per documentation, a ListObject.Add function requires to define a sheet in which the list is added. For example: Set objListObject = ActiveWorkbook.Worksheets(1).ListObjects.Add(SourceType:= xlSrcExternal, _ Source:= Array(strServerName,...
3 Apr 2019 by Member 13999828
hello all: I have an Application (written in VC++ MFC) that needs to play some media files, including MP4, JPEG, HTML only. I thought the easiest way would be to activate the locally installed Applications that are associated with those file extensions, and ask those Apps to open my media...
3 Apr 2019 by #realJSOP
See if there are associated commandline parameters, config files, or failing that, registry entries that you can change. If there aren't any of those, your only recourse is to get the window handle and programatically, change the settings via the given app's UI (and not only is that ugly, but...
3 Apr 2019 by John R. Shaw
1) Use WaitForInputIdle to wait until process has finished initialization. 2) The use EnumThreadWindows to enumerate all top level windows. That should be enough to get started. Start googling.
3 Apr 2019 by megaadam
What @realJSOP says is perfectly valid and helpful. You can fullscreen WMP from the command line. And you can add such parameters in CreateProcess() Fullscreen like so: Command Line Parameters - Windows applications | Microsoft Docs[^]
5 Apr 2017 by Member 13089825
will it possible to create emebedded dialog on listview? For reference of my question you can see below link "https://www.codeproject.com/Articles/4408/Creating-embedded-dialogs-in-MFC?msg=5381464#xx5381464xx"> but in above link its implemented the embedded dialog on dialog itself but in my...
7 Jun 2021 by The Ænema
Learn how to convert any code to a stable shellcode using Visual Studio 2019 and VC++ in easy steps!
13 Nov 2021 by The Ænema
This article brings you a very detailed but easy to learn experience on creating your own x64 PE packer/protector using only VC++!
24 May 2018 by srinivasankrishnaa
I have tried to convert a CString To BYTE* and "BYTE* to CByteArray" in MFC,The CString Has Been Converted To BYTE*. But I'm not able to Convert The Entire Byte* To CByteArray It Returns Partial Data With Some Garbage Values. I Described My Actual Problem Here... What I have tried: CString...
25 May 2018 by KarstenK
Because you use UNICODE the string has 2 byte size and so your buffer is to small. So you double the buffer siz of the CByteArray. arrByte2.SetSize(2*(csData.GetLength()+1)); BTW: You have watched it correctly, but didnt understand it as error hint ;-)
24 May 2018 by Jochen Arndt
A CString is a sequence of TCHAR characters. A TCHAR is a char or a wchar_t depending on the project character set setting (ANSI/multi-byte or Unicode). You can cast the pointer to the data in the CString to BYTE*: const BYTE *pByte = reinterpret_cast(str.GetString()); Note that I...
21 Nov 2018 by Member 10315365
I want to display the tooltip on drop-down list of a combobox using ctooltipctrl. With ctooltipctrl I can able to display the tooltip for individual controls on a dialogu, but for ccombobox it is not working. Could you please help me to resolve this issue. What I have tried: I have created...
23 Mar 2016 by Alya Wu
#include "stdafx.h"#include #include #include #include #include int t = 0;sf::RectangleShape addsnake();std::vectorsnake;sf::RectangleShape...
23 Mar 2016 by KarstenK
Your snake is a vector (like array) you must insert objects, to access them.Pay attention to the scope of your objects. In addsnake you create a local instance of the snake - it hides the global. (So it is a mistake in your implementation)
23 Mar 2016 by Patrice T
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.The debugger allow you to follow the execution line by line, inspect variables and you will see that there...
28 Feb 2016 by Venkat Raghvan
I designed application in VC++ environment of windows,it working fine while I debug it in editor visual studio.But once I build application in Release version it throws memory dump exception and blue screen of death appears finally. What are the possibility of this type of scenario?What I...
28 Feb 2016 by User 59241
Many possible reasons not limited to these:c++ - Common reasons for bugs in release version not present in debug mode - Stack Overflow[^]Can be debugged using these methods:c++ - Program only crashes as release build -- how to debug? - Stack Overflow[^]More tips here:Debugging...
28 Jun 2017 by Coder969
We are migrating our projects from vs2005 to VS2015 .In one of the project we are using below template declaration template In 2005,it is building successfully but in vs2015 getting below error. 'WindowClass': illegal type for non-type template...
9 Aug 2018 by srinivasankrishnaa
Hi Friends, I'm Trying To Design A System Wide Autocomplete Menu Showing Predictions Of The User Input As They Type.How To Implement It... Example:-If I Type "Auto" In Keyboard The Prediction Menu Should Appear With Options Like Automatic,Automobile,etc... I'm Trying It In VC++ Using Visual...
9 Aug 2018 by Jochen Arndt
You would have to install a global keyboard hook, track the active window to know when input goes to a different application or input control, and simulate key strokes upon auto completition. How to do that can be found out with a simple web research: SetWindowsHookEx function (Windows)[^]...
12 Jul 2018 by VishalK_95
Hi, In my VC++ desktop application, currently, I am rendering dialog box based on the attributes available in xml file, Instead of above approach, Is it possible to extract the Information (attributes, Height /width, querystrings etc.,) using Client / Server(web) similar to mvc application in...
7 Apr 2020 by Coder969
I want to understand which hook is used for what purpose. What I have tried: I have googled and only difference I understood is WH_KEYBOAD will inject the dll into the processes but for the WH_KEYBOAD_LL windows will make a direct call to call back function without injecting the dll. So...
16 Sep 2019 by Richard MacCutchan
It is all described at Hooks Overview - Windows applications | Microsoft Docs[^].
7 Apr 2020 by Member 10779791
how i can trace application name or browser url where typing something?? Example if i a\m typing on word then it will return word if it will a exe file then exe file name?? Any suggestion Thankls in Advance
23 Jul 2016 by manikanta3
I studied winmain calls afxwinmainIs it true?What I have tried:I studied in net,can anyone tell me the difference
23 Jul 2016 by Jochen Arndt
See the CodeProject article MFC under the hood[^]. It explains the startup and initialisation process of MFC applications describing which functions are called.
4 Mar 2019 by adityarao31
I can find window version and screen resolution through mfc by different available functions.But how to find display percentage magnification. For example 100%,150%,200% through mfc functions. Please let me know function names. What I have tried: I have googled for the...
29 Mar 2016 by CHill60
Even if we did we would not share this information with you.Hacking is not tolerated on this site.
29 Mar 2016 by Patrice T
Quote:it is not for hacking ... i want to block https websites and shows a message that the website is blocked in the web browser with the https urlThe technique os the same, so no help here for you.We don't help hacker to do malware.
27 Nov 2020 by Member 15003852
I am an intermediate in VC++ and trying to accomplish the following:- 1. Dock a timer created using Windows forms to the extreme right of the taskbar (and to the left of the notification area or system tray). 2. Make it responsive (match its...
10 Oct 2017 by Member 13089825
i have created my own custom control class CMyComboBox and its derived from CCombobox. i have added DrawItem as virtual function but this function is not getting called when loading my dailog could you please tell me how to call drawitem here 2) i need toget the all the combobox functionalities...