Solved

Class design

Posted on 1998-07-22
4
590 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

778 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