Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Class design

Posted on 1998-07-22
4
Medium Priority
?
607 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 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

772 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