Solved

Class design

Posted on 1998-07-22
4
582 Views
Last Modified: 2008-03-10
what's wrong with what i'm doing here????????

//contents of multimonex.h

#include "multimon.h"

class CMultiMonEx
{
public:
      CMultiMonEx(void) {};
      void CacheWorkAreas();
      BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);

      int nMonCount;
      LPRECT lpRectArray;
};

//////////// here are the contents of multimonex.cpp

#include "stdafx.h"
#pragma hdrstop

#include "multimonex.h"

void CMultiMonEx::CacheWorkAreas()
{
      nMonCount = 0;

      delete [] lpRectArray;

      lpRectArray = new RECT[GetSystemMetrics(SM_CMONITORS)];

      EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
}

BOOL CALLBACK CMultiMonEx::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
      AfxMessageBox("asdf");
      return TRUE;
}

who know's what's going on? i'm getting this error:

error C2664: 'xEnumDisplayMonitors' : cannot convert parameter 3 from 'int (struct HMONITOR__ *,struct HDC__ *,struct tagRECT *,long)' to 'int (__stdcall *)(struct HMONITOR__ *,stru
ct HDC__ *,struct tagRECT *,long)'

i haven't a clue why it's doing this and it's making me quite angry!! :) am i missing something here?

for reference, look up EnumDisplayMonitors on msdn if you need to..
0
Comment
Question by:rabbitears
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1168406
Define MonitorEnumProc as a static member function or a global function. Otherwise it has an implicit parameter which is the this pointer.

class CMultiMonEx
{
public:
CMultiMonEx(void) {};
void CacheWorkAreas();
static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);

int nMonCount;
LPRECT lpRectArray;
};

0
 

Author Comment

by:rabbitears
ID: 1168407
this 'technically' worked, however, now i get the following messages.


error LNK2001: unresolved external symbol _xEnumDisplayMonitors@16

error LNK2001: unresolved external symbol _xGetSystemMetrics@4

is it a problem with teh way i might have (or not have) installed the platform sdk?
0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1168408
In your multimonex.cpp,

.
#define COMPILE_MULTIMON_STUBS
#include "multimonex.h"
.

And call InitMultipleMonitorStubs when your application starts up.

Look into multimon.h, you'll understand why they are needed.
0
 

Author Comment

by:rabbitears
ID: 1168409
you, my friend, are the god of programmers :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now