IT Community - Software Programming, Web Development and Technical Support

Visual C++ Tips & Tricks

This is a discussion on Visual C++ Tips & Tricks within the C and C++ Programming forums, part of the Software Development category; Rotating the Image in GDI Hi... Here is the tricks for rotating the Image in GDI+. This code is taken ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #31  
Old 07-30-2007, 05:11 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Post Re: VC++ Tips & Tricks

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 ------------------
Graphics graphics(hdc);
Image image(L"Crayons.jpg");

graphics.DrawImage(&image, 10, 10, image.GetWidth(), image.GetHeight());
image.RotateFlip(Rotate90FlipY);
graphics.DrawImage(&image, 160, 10, image.GetWidth(), image.GetHeight());
//------------------- code ------------------
.....

bye
Thanks
__________________
Karpagarajan. R
Necessity is the mother of invention
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #32  
Old 07-30-2007, 05:54 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

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)
{
return 0;
}
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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #33  
Old 07-30-2007, 05:56 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #34  
Old 07-30-2007, 05:59 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

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,
INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA>,


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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #35  
Old 07-30-2007, 06:03 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

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.h

#import "TestVBdll.dll"
using namespace TestVBdll;
// Add the following code in where you want to call the VB dll function

HRESULT hresult;
CLSID clsid;

CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("TestVBdll.clsdll") ,&clsid);

_clsdll *t;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_ SERVER,__uuidof(_clsdll),(LPVOID *) &t);
if(FAILED(hresult))
{
//AfxMessageBox("Creation Failed");
return "failed";
}

t->TestVBFunction();
t->Release(); //call method
CoUninitialize(); //Unintialize the COM library

// End of the code
.......
bye
thanks
__________________
Karpagarajan. R
Necessity is the mother of invention

Last edited by Booom : 08-09-2007 at 05:43 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #36  
Old 07-30-2007, 06:05 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Default Re: VC++ Tips & Tricks

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 workspace
2. Open the dialog window from resource view
3. Go to Files view in project explorer
4. Select the workspace name and click the right mouse button. select "Insert project in the workspace" menu from the context menu
5. And Open the resource view of the source project
6. Open the dialog window which you would like to copy the design
7. Paste it to the destination dialog window.
Now 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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #37  
Old 07-30-2007, 06:08 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Post Re: VC++ Tips & Tricks

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #38  
Old 07-30-2007, 06:41 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Post Re: VC++ Tips & Tricks

Visual C++ Modifiers
Modifier Meaning
\b backspace
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\" double quote
\' single quote
\<enter> line continuation
\nnn nnn = octal character value
\Oxnn nn = hexadecimal value (not all compilers)
thanks
bye
__________________
Karpagarajan. R
Necessity is the mother of invention

Last edited by Booom : 08-09-2007 at 05:43 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #39  
Old 07-30-2007, 06:44 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Post Re: VC++ Tips & Tricks

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);

g.DrawString("Text on the Screen", greenSolid, new SolidBrush(Color.Green), 10,10);

g.DrawString("Red Text", redStyle, new HatchBrush(HatchStyle.DiagonalCross, Color.Chocolate, Color.Red), 50,40);
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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #40  
Old 07-30-2007, 06:47 AM
Karpagarajan Karpagarajan is offline
D-Web Analyst
 
Join Date: Mar 2007
Posts: 301
Karpagarajan is on a distinguished road
Post Re: VC++ Tips & Tricks

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);

Rect rcLeft=Rect(20,20,100,100);

Region region1(rcLeft);

graphics->DrawRectangle(&myPen, rcLeft);

myPen.SetColor(Color(255, 255, 0, 0));
if(region1.IsVisible(point.x,point.y, graphics))
{
graphics->DrawRectangle(&myPen, rcLeft);
}
bye
thanks
__________________
Karpagarajan. R
Necessity is the mother of invention
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# .Net Tips & Tricks oxygen C# Programming 85 01-08-2009 01:25 AM
SAP Tips & Tricks leoraja8 Operating Systems 0 03-29-2008 01:11 AM
Visual Studio Tips & Tricks SaravananJ C# Programming 197 12-20-2007 04:25 AM
PHP Tips and Tricks Sabari PHP Programming 20 12-18-2007 06:26 AM
.NET tricks & Tips Karpagarajan VB.NET Programming 1 04-23-2007 09:17 AM


All times are GMT -7. The time now is 05:14 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0