This is a discussion on Visual C++ Tips & Tricks within the C and C++ Programming forums, part of the Software Development category; Aligning Text... The following example draws text in a rectangle. Each line of text is centered (side to side), and ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Aligning Text... The following example draws text in a rectangle. Each line of text is centered (side to side), and the entire block of text is centered (top to bottom) in the rectangle. WCHAR string[] = L"Use StringFormat and RectF objects to center text in a rectangle.";bye thanks... ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| Sponsored Links |
| |||
| creating directory with user access persmission Hi friends, here I have given the code for creating directory with user access persmission. Very useful one. This code I got from Platform SDK -> Security section. #define _WIN32_WINNT 0x0500bye thanks
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| WM_MESSAGE => KILL_FOCUS Hi Buddies, here I am giving the solution for ActiveX control illegal closing of Internet explorer. I had found this problem in my activex which was used in web development. The IE was closed with the Illegal error closing message. When I try to find out the problem in debug mode, I had found that there was stack point in my variable assignment statement in VC++. The error happens because of the memory variable not been destroyed after the control was destroyed. The memory was not flushed after the activex control unloaded. I just check the flag in activex WM_MESSAGE => KILL_FOCUS. Hope it may help you in activex coding part. ........... bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi buddies, You can use the following steps to maintain the version in ATL activeX control. 1. Open your Visual C++ ATL project workspace in VC++ IDEby changing these two keys you can maintain your activex control versioning. .............. bye thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 04:44 AM. |
| |||
| ASSERTION An assertion statement specifies a condition that you expect to hold true at some particular point in your program. If that condition does not hold true, the assertion fails, execution of your program is interrupted, and the Assertion Failed dialog box appears. MFC and C Run-Time Library Assertions When the debugger halts because of an MFC or C run-time library assertion, it navigates to the point in the source file where the assertion occurred (if the source is available). The assertion message appears in the Output window as well as the Assertion Failed dialog box. You can copy the assertion message from the Output window to a text window if you want to save it for future reference. The Output window may contain other error messages as well. Examine these messages carefully, because they provide clues to the cause of the assertion failure. _DEBUG Assertion statements compile only when _DEBUG is defined. When _DEBUG is not defined, the compiler treats assertions as null statements. Therefore, assertion statements have zero overhead in your final release program; you can use them liberally in your code without affecting the performance of your Release version and without having to use #ifdefs. ............... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| To enable debugging of a release build, change the following release build options in VC++ 1. On the Project menu, choose Settings. 2. Next to Settings for, select the configuration. 3. In the project tree, under Settings for, select a project. 4. Choose the C/C++ tab. 5. In the Category drop-down box, choose General. 6. In the Debug info drop-down box, choose Program Database. 7. In the Optimizations drop-down box, choose Disable (Debug). 8. On the Link tab, select the Generate Debug Info checkbox. These selections correspond to the /Od and /Zi options, which turn off optimizations and place debug information in the build. After doing this, rebuild and test your program. If the program works fine, it is still possible that you have a memory overwrite, but it is also possible that the optimizations are causing problems on a particular piece of code. ........... thanks bye ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| __uuidof Operator The __uuidof keyword retrieves the GUID attached to the expression. __uuidof ( expression ) The expression can be a type name, pointer, reference, or array of that type, a template specialized on these types, or a variable of these types. The argument is valid as long as the compiler can use it to find the attached GUID. A special case of this intrinsic is when either 0 or NULL is supplied as the argument. In this case, __uuidof will return a GUID made up of zeros. Use this keyword to extract the GUID attached to: An object by the uuid extended attribute. A library block created with the module attribute. The following code (compiled with ole32.lib) will display the uuid of a library block created with the module attribute: // expre_uuidof.cppIn cases where the library name is no longer in scope, you can use __LIBID_ instead of __uuidof. For example: StringFromCLSID(__LIBID_, &lpolestr); ................. thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| From CString to char conversion... Void CStrtoChar() { CString str = " test "; char *p = new char [ str.GetLength () +1 ]; strcpy(p ,str); delete p; } ............... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Check the image file as JPEG... Hi buddies, here is the code to check the given file format is JPEG. Useful one... Bitmap bm(L"Picture.dat");............. thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Disable mouse wheel scrolling Dear Visual C++ Friends, here is the trick To disable mouse wheel in comboBox (MFC) Use it in place of your combobox control, capture the mousewheel messages WM_MOUSEWHEEL and then don't forward them to the base class... .......... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 04:45 AM. |
| |||
| Hi, I need: Get Handle of Main Window from process handle. Here is the answer.... 1. - Use GetProcessId() to get process id from process handle. Use EnumWindows() to look at each top-level window. For each top-level window call GetWindowThreadProcessId() to get the thread id and process id that was used to create the window. Break when you find a top-level window that was created by the specified process handle/id. 2. - Use GetWindowThreadProcessId() to get the thread id and process id that was used to create the window. ........... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Trapping Windows Shutdown and Cancel the shutdown... Hi, Use WM_QUERYENDSESSION for system shutdown in WndProc system function. When that message is received, return 0, pass the WM_CANCELMODE message to that window message and then shutdown on your own by using ExitWindowEx Api . ................ thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| To change attributes for a directory if (! SetFileAttributes("c:\\ResOrg",FILE_ATTRIBUTE_READ ONLY))................ thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Using multiple resource... Hi , Here I am giving the tips for using multiple resource (*.rc) in your Visual C++ project steps 1) Goto menu view-> Resource Includes 2) Resource Includes Window will be open. In that add #include "yourRes.rc" in the Compile - time Directives: textbox 3) Edit the main resource file and add #include yourRes.h behind the #include "afxres.h"now your resource file will be linked .......... thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 04:46 AM. |
| |||
| To get the Cursor (X,Y) position in PreTranslateMessage add the following code. POINTS pts = MAKEPOINTS( pMsg->lParam );in the mouse message trapping like WM_LBUTTONUP ,WM_MOUSELEAVE etc. thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Change the color of the VC++ IDE... by changing the registry values, we can change the color of the Visual C++ IDE... [HKEY_USERS\.Default\Software\Microsoft\Devstudio\6 .0\Format\Source Window] "FontFace"="Comic Sans MS" "FontSize"=dword:00000009 "Text"=hex:c0,80,c0,00,00,00,00,00,12,01,b2,00 "Text Selection"=hex:00,00,00,00,c0,80,c0,00,19,00,19,00 "Current Error/Tag"=hex:ff,ff,ff,00,00,00,80,00,d2,01,b2,01 "Bookmark"=hex:00,00,00,00,00,ff,ff,00,10,00,1 0,00 "Breakpoint"=hex:ff,ff,ff,00,80,00,00,00,10,00 ,10, 00 "Current Statement"=hex:00,00,00,00,ff,ff,00,00,70,00,70,00 "Selection Margin"=hex:d8,e0,f0,00,d8,e0,f0,00,13,00,13,00 "Keyword"=hex:00,ff,00,00,00,00,00,00,10,00,10 ,00 "Comment"=hex:ff,ff,00,00,00,00,00,00,10,00,11 ,00 "Number"=hex:ff,00,00,00,00,00,00,00,10,00,11, 00 "String"=hex:ff,00,00,00,00,00,00,00,10,00,11, 00 "Operator"=hex:00,ff,00,00,00,00,00,00,10,00,1 1,00 "Wizard IDL/ODL Code"=hex:80,80,80,00,00,00,00,00,14,00,15,00 "HTML Element Name"=hex:c0,80,c0,00,00,00,00,00,14,00,15,00 "HTML Attribute Name"=hex:00,ff,00,00,00,00,00,00,14,00,15,00 "HTML Attribute Value"=hex:ff,00,00,00,00,00,00,00,14,00,15,00 "HTML Comment"=hex:ff,ff,00,00,00,00,00,00,14,00,15,00 "HTML Entity"=hex:ff,c0,40,00,00,00,00,00,14,00,15,00 "HTML Tag Delimiter"=hex:00,ff,00,00,00,00,00,00,14,00,15,00 "HTML String"=hex:ff,00,00,00,00,00,00,00,14,00,15,00 "HTML Tag Text"=hex:ff,00,ff,00,00,00,00,00,14,00,15,00 "HTML Operator"=hex:00,ff,00,00,00,00,00,00,14,00,15,00 "HTML Server-Side Script"=hex:00,00,00,00,ff,ff,00,00,14,00,14,00 "Wizard Code"=hex:80,80,80,00,00,00,00,00,14,00,15,00 "User Defined Keywords"=hex:00,00,ff,00,00,00,00,00,14,00,15,00 ........... thanks
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Booom : 08-09-2007 at 04:46 AM. |
| |||
| Hi, here is another tips, When debugging, you can single step into functions by pressing F11. To break the debugging, press Ctrl+F5(this is to run the same application for debugging) thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention |
| |||
| Hi, #include<windows.h> int_stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) { MessageBox(0,"HELLO","TITLE",0); return 0; } This program is not running it produces an error syntax error : missing ';' before identifier 'WinMain' error C2501: 'int_stdcall' : missing storage-class or type specifiers fatal error C1004: unexpected end of file found Error executing cl.exe. How to I solve it. Last edited by roboeinstein : 08-20-2007 at 09:22 AM. |
| |||
| Hi, I hope you have started VC application wrongly. Here is the steps to run the WinMain. It is a Win32 Application. Follow the steps 1. New Project -> In Project tab, select Win32 Application 2. In your source code file for en example, if you started the project as test, then edit "test.cpp" 3. Add your Message box. #include "stdafx.h"thanks ![]()
__________________ Karpagarajan. R Necessity is the mother of invention Last edited by Karpagarajan : 08-21-2007 at 01:09 AM. |
![]() |
| 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 | Date |
| Microsoft Visual C - encyclopedia article about Microsoft Visual C. | |||