Auto arrange editor windows. dalam C++

Posted: Selasa, 05 April 2011 by Alfi Haryadi in
0

print("myedsize.spp");

import editor;

// import the DLL function
import "myedsize.dll" {
void PositionWindow(char*, int, int, bool);
}

// I like 600 pixels by 350 for my edit windows
declare width = 800;
declare height = 500;
declare ViewID;

on editor:>ViewCreated(newView)
{
ViewID = newView.Identifier;
pass(newView);
}

// if a view was activated and it was not
// an existing window then call the DLL
// function to move it
on editor:>ViewActivated(view)
{
if (ViewID == view.Identifier) {
pass(view);
declare newViewTitle = editor.TopView.Window.Title;
PositionWindow(newViewTitle, width, height, false);
ViewID = NULL;
}
pass(view);
}

///////////////////////////////////////////////////////////////

myedsize.cpp


#define WIN32_LEAN_AND_MEAN
#define STRICT
#include
#include
#include
#include

int xPos;
int yPos;
HWND hWndNew;
HWND hWndExisting;
HWND hWndMDI;

enum FileGroup {
Header,
Source,
Other
};

#define PAIRS_NUM 3

static const char* HeaderSourcePairsExt [][PAIRS_NUM] = {
{".h", ".cpp"},
{".hxx", ".cxx"},
{".rh",".rc"},
};

FileGroup GetFileGroup(const char* pszExt)
{
for (int i = 0; i < PAIRS_NUM; i++) if (!strcmpi(pszExt, HeaderSourcePairsExt[i][Header])) return Header; else if (!strcmpi(pszExt, HeaderSourcePairsExt[i][Source])) return Source; return Other; } const char* GetCorrespondingExt(FileGroup fileGroup, const char* pszExt) { for (int i = 0; i= yPos)
yPos = point.y + offset;

return TRUE;
}

extern "C"
void PASCAL _export
PositionWindow(char* title, int width, int height, bool bSourceInLeft = true)
{
// reset x and y pos before each run
xPos = yPos = 0;
hWndExisting = 0;
string::set_case_sensitive(0);

// find the IDE window
HWND hWndIDE = FindWindow("CPPFRAME", NULL);

// find the MDI client which is the client
// window of the IDE
hWndMDI = FindWindowEx(hWndIDE, NULL, "MDIClient", NULL);

// get a handle to the newly-created editor
hWndNew = FindWindowEx(hWndMDI, NULL, "BCW5Editor", title);


char pszName[MAXFILE];
char pszExt[MAXEXT];
GetNameExt(title,pszName,pszExt);

FileGroup fileGroup = GetFileGroup(pszExt);

if (fileGroup != Other) {
RECT rect;
if(fileGroup == (bSourceInLeft ? Source : Header)) {
GetClientRect(hWndMDI, &rect);
xPos = rect.right - width;
}
strcpy(pszExt,GetCorrespondingExt(fileGroup,pszExt));
char pszNameExt[MAXFILE + MAXEXT + 1];
sprintf(pszNameExt,"%s%s",pszName,pszExt);
EnumChildWindows(hWndMDI, FindExistingWindow, (LPARAM)pszNameExt);
if (hWndExisting) {
POINT point;
GetWindowRect(hWndExisting, &rect);
point.x = rect.left;
point.y = rect.top;
ScreenToClient(hWndMDI, &point);
yPos = point.y;
}
else
EnumChildWindows(hWndMDI, EnumProc, (LPARAM)hWndMDI);
}
else
EnumChildWindows(hWndMDI, EnumProc, (LPARAM)hWndMDI);

if (hWndNew)
SetWindowPos(hWndNew, 0, xPos, yPos, width, height, SWP_NOZORDER);
}

0 komentar:


السلام عليكم Assalammualaikum بِسْــــــــــــــــــــــمِ اﷲِارَّحْمَنِ ارَّحِي Cinta itu adalah pembodohan, jangan percaya tentang cinta . . . Karena cinta hanya dapat merusak saraf