Initial
This commit is contained in:
122
mdiwin/VIEWSEL.CPP
Normal file
122
mdiwin/VIEWSEL.CPP
Normal file
@@ -0,0 +1,122 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <mdiwin/windowsx.hpp>
|
||||
#include <mdiwin/string.hpp>
|
||||
#include <mdiwin/main.hpp>
|
||||
#include <mdiwin/profile.hpp>
|
||||
#include <mdiwin/viewsel.hpp>
|
||||
#include <mdiwin/mdiwin.h>
|
||||
|
||||
ViewSelect::ViewSelect(HWND hParent)
|
||||
: mhParent(hParent)
|
||||
{
|
||||
}
|
||||
|
||||
ViewSelect::~ViewSelect()
|
||||
{
|
||||
}
|
||||
|
||||
WORD ViewSelect::selectView(Block<ViewContainer> &viewContainer,WORD &itemIndex,WORD width,WORD height)
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
WORD returnCode;
|
||||
|
||||
if(!copyBlock(viewContainer))return FALSE;
|
||||
mWidth=width;
|
||||
mHeight=height;
|
||||
#if defined(__FLAT__)
|
||||
hInstance=(HINSTANCE)::GetWindowLong(mhParent,GWL_HINSTANCE);
|
||||
#else
|
||||
hInstance=(HINSTANCE)::GetWindowWord(mhParent,GWW_HINSTANCE);
|
||||
#endif
|
||||
if(0!=(returnCode=::DialogBoxParam(hInstance,(LPSTR)"ViewSelect",mhParent,(DLGPROC)DWindow::DialogProcedure,(LONG)((DWindow*)this))))
|
||||
itemIndex=mItemIndex;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
int ViewSelect::DlgProc(UINT message,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
switch(message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
Main::smhBitmap.associate(IDCANCEL,
|
||||
String(STRING_BITMAPCAFOCUSUP,Main::processInstance()),
|
||||
String(STRING_BITMAPCANOFUP,Main::processInstance()),
|
||||
String(STRING_BITMAPCAFOCUSDN,Main::processInstance()),
|
||||
OwnerDraw::NOFOCUS);
|
||||
loadItemData();
|
||||
return TRUE;
|
||||
case WM_DRAWITEM :
|
||||
switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
|
||||
{
|
||||
case IDCANCEL :
|
||||
Main::smhBitmap.handleOwnerButton(IDCANCEL,lParam);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_COMMAND :
|
||||
switch(GET_WM_COMMAND_ID(wParam,lParam))
|
||||
{
|
||||
case VIEWSEL_LIST :
|
||||
if(handleListBoxEvent(lParam))
|
||||
{
|
||||
Main::smhBitmap.freeButton(IDCANCEL);
|
||||
::EndDialog(GetHandle(),TRUE);
|
||||
}
|
||||
break;
|
||||
case IDCANCEL :
|
||||
Main::smhBitmap.freeButton(IDCANCEL);
|
||||
::EndDialog(GetHandle(),FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WORD ViewSelect::copyBlock(Block<ViewContainer> &viewContainer)
|
||||
{
|
||||
size_t size((int)viewContainer.size());
|
||||
|
||||
if(!size)return FALSE;
|
||||
mViewContainer.remove();
|
||||
for(int i=0;i<size;i++)mViewContainer.insert(&viewContainer[i]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ViewSelect::loadItemData(void)
|
||||
{
|
||||
String tabString(STRING_TABSTRING,Main::processInstance());
|
||||
size_t size((int)mViewContainer.size());
|
||||
String tempString;
|
||||
String itemIndex;
|
||||
Profile iniProfile;
|
||||
|
||||
tempString.reserve(String::MaxString);
|
||||
for(int i=0;i<size;i++)
|
||||
{
|
||||
::sprintf(itemIndex,"%d",i);
|
||||
::GetWindowText((mViewContainer[i].windowPtr())->handle(),tempString,String::MaxString-1);
|
||||
iniProfile.makeFileName(tempString);
|
||||
for(int i=0;i<NumTabs;i++)tempString+=tabString;
|
||||
tempString+=itemIndex;
|
||||
::SendDlgItemMessage(GetHandle(),VIEWSEL_LIST,LB_ADDSTRING,0,(LPARAM)(LPCSTR)tempString);
|
||||
}
|
||||
}
|
||||
|
||||
WORD ViewSelect::handleListBoxEvent(LPARAM lParam)
|
||||
{
|
||||
String tabString(STRING_TABSTRING,Main::processInstance());
|
||||
String tempString;
|
||||
LRESULT curSel;
|
||||
char *ptr;
|
||||
|
||||
if(HIWORD(lParam)!=LBN_DBLCLK)return FALSE;
|
||||
tempString.reserve(String::MaxString);
|
||||
curSel=::SendDlgItemMessage(GetHandle(),VIEWSEL_LIST,LB_GETCURSEL,0,0L);
|
||||
::SendDlgItemMessage(GetHandle(),VIEWSEL_LIST,LB_GETTEXT,(WPARAM)curSel,(LPARAM)(LPSTR)tempString);
|
||||
ptr=tempString;
|
||||
ptr=::strtok(ptr,tabString);
|
||||
ptr=::strtok(0,tabString);
|
||||
mItemIndex=::atoi(ptr);
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user