blob: e0cb8247432dcbfc3e747e8786500182a79f9a79 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
//-----------------------------------------------------------------------------
// Copyright (C) 2001 Radical Entertainment Ltd. All rights reserved.
//
// mayahandles.cpp
//
// Description: Class to store and retrieve maya handles as generic pointers.
//
// Modification History:
// + Created Oct 15, 2001 -- bkusy
// + More MFC goodness -- Cary Brisebois
//-----------------------------------------------------------------------------
//----------------------------------------
// System Includes
//----------------------------------------
//----------------------------------------
// Project Includes
//----------------------------------------
#include "mayahandles.h"
#include "stdafx.h"
#include "maya/mglobal.h"
//----------------------------------------
// Forward References
//----------------------------------------
//----------------------------------------
// Constants, Typedefs and Statics
//----------------------------------------
void* MayaHandles::m_hInstance = 0;
void* MayaHandles::m_HWND = 0;
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
char str[1024];
::GetWindowText(hwnd, str, 1024);
MString mayaVersion = MGlobal::mayaVersion();
char version[256];
sprintf( version, "Maya %s", mayaVersion.asChar() );
if(strncmp(str, version, strlen(version)) == 0) //This is silly.
{
*(HWND*)lParam = hwnd;
return FALSE;
}
return TRUE;
}
//-----------------------------------------------------------------------------
// S e t H I n s t a n c e
//
// Synopsis:
//
// Parameters: NONE
//
// Returns: NOTHING
//
// Constraints: NONE
//
//-----------------------------------------------------------------------------
void MayaHandles::SetHInstance( void* hInstance )
{
m_hInstance = hInstance;
}
//-----------------------------------------------------------------------------
// G e t H I n s t a n c e
//
// Synopsis:
//
// Parameters: NONE
//
// Returns: NOTHING
//
// Constraints: NONE
//
//-----------------------------------------------------------------------------
void* MayaHandles::GetHInstance()
{
return m_hInstance;
}
void* MayaHandles::GetHWND()
{
if ( m_HWND == 0 )
{
HWND hWnd = NULL;
EnumChildWindows(::GetDesktopWindow(), EnumChildProc, (long)&hWnd);
if(hWnd == NULL)
{
// houston we have a problem
MGlobal::displayError("can't find Maya window");
}
else
{
m_HWND = hWnd;
}
}
return m_HWND;
}
|