Solved

Class design

Posted on 1998-07-22
4
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

635 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