⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winrect.cpp

📁 Notepad++ is a generic source code editor (it tries to be anyway) and Notepad replacement written in
💻 CPP
字号:
////////////////////////////////////////////////////////////////
// MSDN Magazine -- July 2001
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0. Runs on Win 98 and probably Win 2000 too.
// Set tabsize = 3 in your editor.
//
//#include "StdAfx.h"
#include "windows.h"
#include <assert.h>
#include "WinMgr.h"

//////////////////
// Construct from args
//
WINRECT::WINRECT(WORD f, UINT id, LONG p)
{
	memset(this, 0, sizeof(WINRECT));
	flags = f;
	nID = id;
	param = p;
}

//////////////////
// Get the parent of a given WINRECT. To find the parent, chase the prev
// pointer to the start of the list, then take the item before that in
// memory. 
//
WINRECT* WINRECT::Parent()
{
	WINRECT* pEntry = NULL;
	for (pEntry=this; pEntry->Prev(); pEntry=pEntry->Prev()) {
		; // go backwards to the end
	}
	// the entry before the first child is the group
	WINRECT *parent = pEntry-1;
	assert(parent->IsGroup());
	return parent;
}

//////////////////
// Get group margins
//
BOOL WINRECT::GetMargins(int& w, int& h)
{
	if (IsGroup()) {
		w=(short)LOWORD(param);
		h=(short)HIWORD(param);
		return TRUE;
	}
	w=h=0;
	return FALSE;
}

//////////////////
// Initialize map: set up all the next/prev pointers. This converts the
// linear array to a more convenient linked list. Called from END_WINDOW_MAP.
//
WINRECT* WINRECT::InitMap(WINRECT* pWinMap, WINRECT* parent)
{
	assert(pWinMap);

	WINRECT* pwrc = pWinMap;  // current table entry
	WINRECT* prev = NULL;	  // previous entry starts out none

	while (!pwrc->IsEndGroup()) {
		pwrc->prev=prev;
		pwrc->next=NULL;
		if (prev)
			prev->next = pwrc;
		prev = pwrc;
		if (pwrc->IsGroup()) {
			pwrc = InitMap(pwrc+1,pwrc); // recurse! Returns end-of-grp
			assert(pwrc->IsEndGroup());
		}
		pwrc++;
	}
	// safety checks
	assert(pwrc->IsEndGroup());
	assert(prev);
	assert(prev->next==NULL);
	return parent ? pwrc : NULL;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -