PropertyGrid successfully implemented.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -52,3 +52,4 @@ G3DTest.suo
|
|||||||
G3DTest.suo
|
G3DTest.suo
|
||||||
stderr.txt
|
stderr.txt
|
||||||
desktop.ini
|
desktop.ini
|
||||||
|
main.cpp
|
||||||
|
|||||||
2
Demo.h
2
Demo.h
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include "CameraController.h"
|
#include "CameraController.h"
|
||||||
|
#include "PropertyWindow.h"
|
||||||
|
|
||||||
class Demo { // : public GApp {
|
class Demo { // : public GApp {
|
||||||
public:
|
public:
|
||||||
@@ -45,6 +46,7 @@ class Demo { // : public GApp {
|
|||||||
HWND _hwndToolbox;
|
HWND _hwndToolbox;
|
||||||
HWND _buttonTest;
|
HWND _buttonTest;
|
||||||
HWND _hwndRenderer;
|
HWND _hwndRenderer;
|
||||||
|
PropertyWindow* _propWindow;
|
||||||
protected:
|
protected:
|
||||||
Stopwatch m_graphicsWatch;
|
Stopwatch m_graphicsWatch;
|
||||||
Stopwatch m_logicWatch;
|
Stopwatch m_logicWatch;
|
||||||
|
|||||||
87
PropertyWindow.cpp
Normal file
87
PropertyWindow.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include "WindowFunctions.h"
|
||||||
|
#include "propertyGrid.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#include "PropertyWindow.h"
|
||||||
|
|
||||||
|
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
||||||
|
if (propWind==NULL)
|
||||||
|
{
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case WM_SIZE:
|
||||||
|
{
|
||||||
|
propWind->onResize();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) {
|
||||||
|
|
||||||
|
if (!createWindowClass("propHWND",PropProc,hThisInstance))
|
||||||
|
return false;
|
||||||
|
_hwndProp = CreateWindowEx(
|
||||||
|
WS_EX_TOOLWINDOW,
|
||||||
|
"propHWND",
|
||||||
|
"Prop Test",
|
||||||
|
WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
300,
|
||||||
|
660,
|
||||||
|
NULL, // parent
|
||||||
|
NULL, // menu
|
||||||
|
hThisInstance,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
|
||||||
|
|
||||||
|
PROPGRIDITEM pItem;
|
||||||
|
PropGrid_ItemInit(pItem);
|
||||||
|
|
||||||
|
pItem.lpszCatalog="Test";
|
||||||
|
pItem.lpszPropName="Test2";
|
||||||
|
pItem.lpszzCmbItems="What";
|
||||||
|
pItem.lpszPropDesc="Description";
|
||||||
|
pItem.lpCurValue=0;
|
||||||
|
|
||||||
|
pItem.iItemType=PIT_EDIT;
|
||||||
|
PropGrid_Enable(_propGrid,true);
|
||||||
|
ShowWindow(_propGrid,SW_SHOW);
|
||||||
|
PropGrid_AddItem(_propGrid,&pItem);
|
||||||
|
PropGrid_SetItemHeight(_propGrid,20);
|
||||||
|
PropGrid_ShowToolTips(_propGrid,TRUE);
|
||||||
|
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
|
||||||
|
PropGrid_ExpandAllCatalogs(_propGrid);
|
||||||
|
|
||||||
|
SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
|
||||||
|
_redraw(_hwndProp);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyWindow::PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance) {
|
||||||
|
onCreate(x, y, sx, sy, hThisInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyWindow::onResize()
|
||||||
|
{
|
||||||
|
_redraw(_hwndProp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertyWindow::_redraw(HWND hwnd)
|
||||||
|
{
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(hwnd,&rect);
|
||||||
|
SetWindowPos(_propGrid, NULL, 0, 0, rect.right, rect.bottom, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
12
PropertyWindow.h
Normal file
12
PropertyWindow.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class PropertyWindow {
|
||||||
|
public:
|
||||||
|
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
|
||||||
|
bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance);
|
||||||
|
void onResize();
|
||||||
|
private:
|
||||||
|
HWND _propGrid;
|
||||||
|
HWND _hwndProp;
|
||||||
|
void _redraw(HWND hwnd);
|
||||||
|
};
|
||||||
61
main.cpp
61
main.cpp
@@ -38,7 +38,7 @@
|
|||||||
#include "ax.h"
|
#include "ax.h"
|
||||||
#include <cguid.h>
|
#include <cguid.h>
|
||||||
#include "IEBrowser.h"
|
#include "IEBrowser.h"
|
||||||
#include "propertyGrid.h"
|
#include "PropertyWindow.h"
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
#if G3D_VER < 61000
|
#if G3D_VER < 61000
|
||||||
@@ -141,7 +141,7 @@ Demo::Demo(const GAppSettings& settings,HWND parentWindow) { //: GApp(settings,w
|
|||||||
|
|
||||||
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
|
SetWindowLongPtr(_hWndMain,GWL_USERDATA,(LONG)this);
|
||||||
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
|
SetWindowLongPtr(_hwndRenderer,GWL_USERDATA,(LONG)this);
|
||||||
|
_propWindow = new PropertyWindow(0,0,200,640,hThisInstance);
|
||||||
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
|
IEBrowser* webBrowser = new IEBrowser(_hwndToolbox);
|
||||||
webBrowser->navigateSyncURL(L"http://scottbeebiwan.tk/g3d/toolbox/");
|
webBrowser->navigateSyncURL(L"http://scottbeebiwan.tk/g3d/toolbox/");
|
||||||
}
|
}
|
||||||
@@ -1349,8 +1349,6 @@ void Boop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
Demo *app = (Demo *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
||||||
@@ -1579,11 +1577,6 @@ void Demo::onCreate(HWND parentWindow)
|
|||||||
//SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo);
|
//SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openProperties(Instance inst)
|
|
||||||
{
|
|
||||||
//Open the properties window and feed either the selected instance or the datamodel itself if no instance is selected
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
try{
|
try{
|
||||||
hresult = OleInitialize(NULL);
|
hresult = OleInitialize(NULL);
|
||||||
@@ -1616,8 +1609,6 @@ int main(int argc, char** argv) {
|
|||||||
settings.window.center = true;
|
settings.window.center = true;
|
||||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||||
|
|
||||||
if (!createWindowClass("propHWND",WndProc,hThisInstance))
|
|
||||||
return false;
|
|
||||||
if (!createWindowClass("mainHWND",WndProc,hThisInstance))
|
if (!createWindowClass("mainHWND",WndProc,hThisInstance))
|
||||||
return false;
|
return false;
|
||||||
if (!createWindowClass("toolboxHWND",ToolboxProc,hThisInstance))
|
if (!createWindowClass("toolboxHWND",ToolboxProc,hThisInstance))
|
||||||
@@ -1625,54 +1616,6 @@ int main(int argc, char** argv) {
|
|||||||
if (!createWindowClass("G3DWindow",G3DProc,hThisInstance))
|
if (!createWindowClass("G3DWindow",G3DProc,hThisInstance))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
HWND hwndProp = CreateWindowEx(
|
|
||||||
WS_EX_TOOLWINDOW,
|
|
||||||
"propHWND",
|
|
||||||
"PropertyGrid",
|
|
||||||
WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
CW_USEDEFAULT,
|
|
||||||
300,
|
|
||||||
660,
|
|
||||||
NULL, // parent
|
|
||||||
NULL, // menu
|
|
||||||
hThisInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
ShowWindow(hwndProp,SW_SHOW);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HWND propGrid = New_PropertyGrid(hwndProp, 1000);
|
|
||||||
//InitPropertyGrid(GetModuleHandle(NULL));
|
|
||||||
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
|
|
||||||
pItem.lpszCatalog="Test";
|
|
||||||
pItem.lpszPropName="Test2";
|
|
||||||
pItem.lpszzCmbItems="What\0\0";
|
|
||||||
pItem.lpszPropDesc="Description";
|
|
||||||
pItem.iItemType = PIT_COMBO;
|
|
||||||
pItem.lpCurValue=0;
|
|
||||||
//PROPGRIDITEM FauxExplorerItem;
|
|
||||||
//PropGrid_ItemInit(FauxExplorerItem);
|
|
||||||
//FauxExplorerItem.lpszCatalog="Test";
|
|
||||||
//FauxExplorerItem.lpszPropName = "Editable Combo Field";
|
|
||||||
//FauxExplorerItem.lpszzCmbItems = "Test1\0Test2\0Test3";
|
|
||||||
//FauxExplorerItem.lpszPropDesc = "Press F4 to view drop down.";
|
|
||||||
//FauxExplorerItem.iItemType = PIT_EDITCOMBO;
|
|
||||||
//FauxExplorerItem.lpCurValue = 1;
|
|
||||||
//PropGrid_AddItem(propGrid, &FauxExplorerItem);
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
|
||||||
|
|
||||||
ShowWindow(propGrid,SW_SHOW);
|
|
||||||
PropGrid_AddItem(propGrid,&pItem);
|
|
||||||
PropGrid_SetItemHeight(propGrid, 20);
|
|
||||||
PropGrid_ShowToolTips(propGrid, TRUE);
|
|
||||||
PropGrid_ShowPropertyDescriptions(propGrid, TRUE);
|
|
||||||
PropGrid_ExpandAllCatalogs(propGrid);
|
|
||||||
PropGrid_Enable(propGrid,true);
|
|
||||||
HWND hwndMain = CreateWindowEx(
|
HWND hwndMain = CreateWindowEx(
|
||||||
WS_EX_ACCEPTFILES,
|
WS_EX_ACCEPTFILES,
|
||||||
"mainHWND",
|
"mainHWND",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// Used by Dialogs.rc
|
// Used by Dialogs.rc
|
||||||
//
|
//
|
||||||
#define IDI_ICON1 102
|
#define IDI_ICON1 102
|
||||||
|
#define IDC_PROPERTYGRID 2000
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user