Solved

Class design

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

730 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