4 Replies - 1250 Views - Last Post: 16 July 2008 - 10:51 AM Rate Topic: -----

#1 Nickshawn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-September 07

C++ file in vb.net

Posted 16 July 2008 - 08:43 AM

I have found a c++ class that does what i need, but i don't know how to call it. I have added the .h and .cpp by reference, but i need like a button and label that will show where the taskbar is.

----------------------------------------------------------------------*/
#include "stdafx.h"
#include "ShowWindowFromTray.h"
#include "Shellapi.h"

#pragma warning( disable: 4706 )
#define COMPILE_MULTIMON_STUBS
#include <multimon.h>

enum TaskBarPosition { knTBPNone = 0, knTBPBottom, knTBPTop, knTBPLeft, knTBPRight, knTBPMax };

//
//	This is not static because it is useful and could be used elsewhere!
bool GetDisplayWorkArea( const RECT &rcSource, RECT &rc )
{
	HMONITOR hMon = ::MonitorFromRect( &rcSource, MONITOR_DEFAULTTONULL );
	if( hMon )
	{
		MONITORINFO m = { sizeof( m ) };
		if( ::GetMonitorInfo( hMon, &m ) )
		{
			rc = m.rcWork;
			return true;
		}
	}
	return false;
}


static BOOL GetTaskBarPositionAndMetrics( TaskBarPosition &position, RECT &rcWorkArea )
//
//	Get the position of the task bar
//
//	Also, return some useful metrics for use later (as we have them we may as well use them)
//
{
	BOOL bRetVal = FALSE;

	//
	//	Default to none just in case we fail.
	position = knTBPNone;

	//
	//	Find out where the taskbar is
	APPBARDATA abd ={ sizeof( APPBARDATA ) };
	if( ::SHAppBarMessage( ABM_GETTASKBARPOS, &abd ) )
	{
		//
		//	Just a reference to make the code read better
		const RECT &rcTaskBar = abd.rc;

		//
		//	Figure out the screen dimensions for the monitor that has the task bar
		if( ::GetDisplayWorkArea( rcTaskBar, rcWorkArea ) )
		{


			//
			//	If the task bar is at the top or bottom then the icon tray is on the right.
			//	If it's on the left or right then the icon tray is at the bottom.
			const UINT uTaskBarHeight = rcTaskBar.bottom - rcTaskBar.top;
			const UINT uTaskBarWidth = rcTaskBar.right - rcTaskBar.left;

			//
			//	From here we can't fail...
			bRetVal = TRUE;

			if( uTaskBarHeight > uTaskBarWidth )
			{
				//
				//	Taskbar is vertical
				if( rcTaskBar.right > rcWorkArea.right )
				{
					position = knTBPRight;
				}
				else
				{
					position = knTBPLeft;
				}
			}
			else
			{
				//
				//	Taskbar is horizontal
				if( rcTaskBar.bottom > rcWorkArea.bottom )
				{
					position = knTBPBottom;
				}
				else
				{
					position = knTBPTop;
				}
			}
		}
	}
	return bRetVal;
}





This code is from http://www.gipsysoft...es/TrayMessage/

Is This A Good Question/Topic? 0
  • +

Replies To: C++ file in vb.net

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: C++ file in vb.net

Posted 16 July 2008 - 09:07 AM

Have you tried the following namespace?
      My.Computer.Screen
 

Was This Post Helpful? 0
  • +
  • -

#3 Nickshawn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-September 07

Re: C++ file in vb.net

Posted 16 July 2008 - 09:37 AM

Not exactly sure what you mean, should I add that to the .cpp file?
Was This Post Helpful? 0
  • +
  • -

#4 WayneSpangler  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 106
  • Joined: 22-March 08

Re: C++ file in vb.net

Posted 16 July 2008 - 10:07 AM

The c++ file has to be compiled to a .dll file and then referenced in your program.
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: C++ file in vb.net

Posted 16 July 2008 - 10:51 AM

View PostNickshawn, on 16 Jul, 2008 - 05:37 PM, said:

Not exactly sure what you mean, should I add that to the .cpp file?


Everything that the c++ code is doing, is available through the various methods available in the namespace.
' Size of Primary Screen without taskbar
My.Computer.Screen.Bounds.Width
My.Computer.Screen.Bounds.Height
' Size of area above taskbar
My.Computer.Screen.WorkingArea.Width 
My.Computer.Screen.WorkingArea.Height



Just use it in VB.net code and forget about the C++.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1