This is a discussion on Visual C++ Tips & Tricks within the C and C++ Programming forums, part of the Software Development category; The following macros make it easy to add reminders which are displayed when code is compiled. You can double click ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| The following macros make it easy to add reminders which are displayed when code is compiled. You can double click on a reminder in the Output Window and jump to the line. Useful for marking TODOs. // Statements like: thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| Sponsored Links |
| |||
| A bug with namespaces causes Visual C++ 6.0 to move a namespace to root in cases where it should only be in another namespace. Here is a small example: #include <string> The code above should not compile since string in the main function is unknown, i.e. it should still be in the std namespace. This bug caused me to redo some code in IPL98, instead of writing using namespace std inside the ipl namespace, I am forced to explecitely write what functions/classes I need from the std library, for instance using std::string. This works. thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Dealing with Palettes I have written about palettes , I will say only that the application has a single palette that is created as a simple color cube to give a rough variety of colors. The application needs to handle two palette messages, and these are taken care of by these two functions: void CPaintWnd::OnPaletteChanged(CWnd* pFocusWnd) { // See if the change was caused by us and ignore it if not. if (pFocusWnd != this) { OnQueryNewPalette(); } } BOOL CPaintWnd::OnQueryNewPalette() { // We are going active, so realize our palette. if (m_pPal) { CDC* pdc = GetDC(); CPalette *poldpal = pdc->SelectPalette(m_pPal, FALSE); UINT u = pdc->RealizePalette(); ReleaseDC(pdc); if (u != 0) { // Some colors changed, so we need to repaint. InvalidateRect(NULL, TRUE); // Repaint the lot. return TRUE; // Say we did something. } } return FALSE; // Say we did nothing. } That's more or less all there is to it, except to know that each time a new CDIB or CSprite object image is loaded, it must be mapped to this common palette by calling its MapColorsToPalette function. The CCrayon and CEraser classes are both derived from CDrawingTool, which does this for you in its Load function: void CDrawingTool::Load(UINT uiID, CPalette* pPal) { ASSERT(uiID); ASSERT(pPal); BOOL b = CSprite::Load(uiID); ASSERT(b); MapColorsToPalette(pPal); } thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Karpagarajan : 04-13-2007 at 05:01 AM. |
| |||
| Hi Here is the tips for avoiding the build errors in Visual C++. To avoid build errors, when upgrading from one version of the compiler to another, make sure you have deleted your old PDB, PCH files. thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:41 AM. |
| |||
| Here is the simple way to call URL... ________________________________________ Hi.. All Here i give a simple way to call the URL using visual c++ code "ShellExecute" ShellExecute(NULL,"open", "www.google.com", "", "c:\\", SW_SHOW); thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:41 AM. |
| |||
| Hi. Here is another tips. When i tried to create a dll in c using visual c++ compiler i received these errors. LNK2001: unresolved external symbol _main Debug/windll.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Can you people tell why this error was occured? .... Yeah.. The problem is I am creating a executable file hence the compiler is looking for main method.. Inorder to create a DLL file we have to some manipulation in the project properties. i.e open the project properties window and select the link tab. change the output file from exe to DLL and the "Project Options" text box change the "subsytem console" to "dll" Thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:42 AM. |
| |||
| Hi All... I developed one application which contains the listviews. In that I gave the backgournd image for the listview. In Some situations I need that listview should be blank(e.i without the background). I dont know how to do this. I spent lot time to search in that. Its simple. But that time i didnt know the code. After some R&D i found it. Do u know whats that? Yeah this is what i had written in my code. m_cListCtrl.SetBkImage( HBITMAP(0)); (HBITMAP(0) will return the NULL HBITMAP.) bye .......... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi friends... Today I am going to give the tips and tricks for the GDI+. When I was new to the GDI+, I was not able to include the GDI+ library files into my project. Here We will see how to link the GDI+ into our project. 1.) Go to Project setting by pressing Alt+F7. 2.) Go to Link tab in the Project Property, In that select Input from the category combo list. 3.) Include the GDIplus.dll file path 4.) Then go to Application class header file(e.g App.h). In that Add the following code to link the GDI+ library class and functions. #include <vector> #include "myGdiPlus.h" using namespace Gdiplus; //Image Thread Handle ULONG_PTR gdiplusToken; //And Start the GDIplus in Application InitInstance() //begin: initialize GDI+ GdiplusStartupInput gdiplusStartupInput; VERIFY(GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL ) == Ok ); //end: initialize GDI+ //And Shutdown the GDIplus in Application ExitInstance() //begin: shutdown GDI+ GdiplusShutdown(gdiplusToken); //end: shutdown GDI+ Now your application will support the GDI+ class and functions ........... bye Thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi friends... Here another tips. Using GDI+, You can get the image from HBITMAP. This is why i gave as a tips, some time we will need to load a picture in Static control or listview item. For that we need HBITMAP. //The following code will help for this.Hope this will help you .............. bye Thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi... Today's tips 1. You must initialize references and non-static const members in the member-initialization list of constructor 2. To get some new powerful and useful source editor commands, click Macros on the Tools menu and load the sample macrofile bye ...... thanks
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Rotating the Image in GDI Hi... Here is the tricks for rotating the Image in GDI+. This code is taken from the Window SDK GDI+ help document. This code is simple and very useful. //------------------- code ------------------..... bye Thanks
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi Visual C++ friends, Here is the another tips for getting the x,y cordination while mouse move This is why i gave as tips, it will help to get the point structure from the lparam. When i used ATL control, The mouse move message handler gave the function called LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)in that i couldnt know how to get the (x,y) mouse point the paramters in this function called LPARAM is used to hold the mouse (x,y) coordination. To typecast the LPARAM structure into point structure, use the following code CPoint pint(lParam);hope the above information will help u. bye ..... Thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:42 AM. |
| |||
| Hi VC++ friends Anybody tell me how to assign a string value to the string variable which contains double quotes. Say for example CString mText=_T("My name is "Kabil" . ");? Here is the tips for that. For that you have to use escape sequence( \ ) CString mText=_T("My name is \"Kabil\" . ");bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi ... this tips is good one... Using ATL in visual c++ I have received one error while implementing the ATL Objectsafty script "error C2065: 'm_dwCurrentSafety' : undeclared identifier"I had struggled with clearing this error. After some internet search, i have found that it was because of not including the ATL IObjectSafetyImpl statement in ATL class declaration. After adding the following code, i didnt get the error. public IObjectSafetyImpl<CNewUpl, Hope it will help u to develop the error free controls in vc++ ..... bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:43 AM. |
| |||
| Hi Guys, Here this is a very useful tip. This is to call the VB DLL function in Visual C++ module. DO the following code // Add the following code in the StdAfx.husing namespace TestVBdll; // Add the following code in where you want to call the VB dll function....... bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:43 AM. |
| |||
| Hi, here is the tips for copying the screen designs in one project to another project in visual c++. Steps 1. Open the destination project workspaceNow you will have the screen design bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:43 AM. |
| |||
| Hi friends, How can I shutdown the system programmatically? The appropriately named ExitWindows() and ExitWindowsEx() functions do the trick. On Win9x, using them is pretty straightforward. On NT, however, the calling process must enable the SE_SHUTDOWN_NAME privilege explicitly before calling either of these functions. How to do this? by using AdjustTokenPrivileges(). You'll find examples on both issues below. Also, on NT you'll find a very handy function called InitiateSystemShutdown(). It can basically do the same as ExitWindows(), except it allows you to shutdown remote systems. Remember that to do this, you need to have the SE_REMOTE_SHUTDOWN privilege granted on the remote computer, though. bye thanks
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Visual C++ Modifiers Modifier Meaning \b backspacethanks bye
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:43 AM. |
| |||
| GDI Font in Visual C++ Hi buddies, This tips is about fonts in GDI+(very useful). The System.Drawing.Font class represents a font type. For example, Font fnt = new Font("Arial", 14); Creates a font type verdana with size 14. You can also use a FontStyle as an argument when constructing a font. Font redStyle = new Font("Tahoma", 20, FontStyle.Bold|FontStyle.Italic|FontStyle.Underlin e);The FontStyle Enumeration defines these styles. bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 05:44 AM. |
| |||
| Using Region in GDI+ programming.... Hi friends here is the sample code for GDI+ region in VC++(Good one) Pen myPen(Color(255, 0, 0, 0), 1);bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-c-programming/531-visual-c-tips-tricks.html | |||
| Posted By | For | Type | |