Skip to content

Commit

Permalink
[#57] Support for KryoFlux and associated images (Part 193: Introduct…
Browse files Browse the repository at this point in the history
…ion and usage of checkbox with hyperlink)
  • Loading branch information
tomas-nestorovic committed Mar 20, 2024
1 parent ad82904 commit 09bac02
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Main/res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,9 @@ BEGIN
CONTROL "Verify &written data (including requested data errors, if any)",
ID_VERIFY_SECTOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,
229,195,10
CONTROL "&Prefer relative over absolute seeking",ID_SEEK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,240,131,10
CONTROL "&Prefer relative over absolute seeking (see why)",
ID_SEEK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,240,163,
10
END

IDR_FDD_LATENCY DIALOG DISCARDABLE 0, 0, 154, 85
Expand Down Expand Up @@ -1840,9 +1841,7 @@ BEGIN
ES_NUMBER | WS_DISABLED | NOT WS_BORDER
LTEXT "-th cyl.",ID_ADD,119,214,22,8,NOT WS_GROUP
CONTROL "Use jitter and other &corrections",ID_TRACK,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,230,112,10
CONTROL "(<a id=""correction"">Settings</a>)",ID_TIME,"SysLink",
WS_TABSTOP,119,231,49,10
BS_AUTOCHECKBOX | WS_TABSTOP,7,230,211,10
CONTROL "&Verify formatted/written tracks (recommended)",
ID_VERIFY_TRACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,
241,211,10
Expand Down
1 change: 1 addition & 0 deletions Main/src/CapsBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@
)
)
CheckDlgButton( ID_READABLE, false ); // this option is never ticked for Unknown DOS
ConvertDlgCheckboxToHyperlink( ID_TRACK, ID_TIME, L"Use jitter and other &corrections (<a id=\"correction\">Settings</a>)" );
}

void DoDataExchange(CDataExchange* pDX) override{
Expand Down
8 changes: 6 additions & 2 deletions Main/src/FDD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ Utils::Information(buf);}
)
)
CheckDlgButton( ID_READABLE, false ); // this option is never ticked for Unknown DOS
ConvertDlgCheckboxToHyperlink( ID_SEEK, ID_STEPPING, L"&Prefer relative over absolute seeking (<a>see why</a>)" );
}
void __exchangeLatency__(CDataExchange* pDX){
// exchange of latency-related data from and to controls
Expand Down Expand Up @@ -1658,7 +1659,9 @@ Utils::Information(buf);}
OnPaint();
return 0;
case WM_NOTIFY:
if (wParam==ID_AUTO && ((LPNMHDR)lParam)->code==NM_CLICK){
if (((LPNMHDR)lParam)->code!=NM_CLICK)
break;
if (wParam==ID_AUTO){
autodetermineLatencies: // automatic determination of write latency values
// . defining the Dialog
class CLatencyAutoDeterminationDialog sealed:public Utils::CRideDialog{
Expand Down Expand Up @@ -1736,7 +1739,8 @@ Utils::Information(buf);}
}
}
}
}
}else if (wParam==ID_STEPPING)
app.GetMainWindow()->OpenApplicationFaqWebPage(_T("faq_fddCalibration.html"));
break;
case WM_COMMAND:
switch (wParam){
Expand Down
50 changes: 50 additions & 0 deletions Main/src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,56 @@ namespace Utils{
::InvalidateRect(hStdBtn,nullptr,TRUE);
}

void CRideDialog::ConvertDlgCheckboxToHyperlink(WORD id,WORD idHyperlinkControl,LPCWSTR hyperlinkControlText) const{
// converts an existing standard check-box to one with a hyperlink in its text
static struct{
WNDPROC checkbox0;

static LRESULT WINAPI Checkbox(HWND hCheckbox,UINT msg,WPARAM wParam,LPARAM lParam){
switch (msg){
case WM_SETFOCUS:
case WM_KILLFOCUS:
::InvalidateRect( GetWindowUserData<HWND>(hCheckbox), nullptr, TRUE );
break;
case WM_NOTIFY:
return ::SendMessage( ::GetParent(hCheckbox), msg, wParam, lParam ); // forward to Dialog
case WM_PAINT:{
// . first draw the Checkbox
const LRESULT result=::CallWindowProc( wndProc.checkbox0, hCheckbox, msg, wParam, lParam );
// . then immediately refresh the Hyperlink
const HWND hHyperlink=GetWindowUserData<HWND>(hCheckbox);
::RedrawWindow(
hHyperlink, nullptr, nullptr,
RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE
);
// . if Checkbox focused, draw focus rectangle around the Hyperlink
if (::GetFocus()==hCheckbox){
RECT rcClient;
::GetClientRect( hHyperlink, &rcClient );
const HDC dc=::GetDC(hHyperlink);
::DrawFocusRect( dc, &rcClient );
::ReleaseDC( hHyperlink, dc );
}
return result;
}
}
return ::CallWindowProc( wndProc.checkbox0, hCheckbox, msg, wParam, lParam );
};
} wndProc;

const HWND hStdCheckbox=GetDlgItemHwnd(id);
wndProc.checkbox0=Utils::SubclassWindow( hStdCheckbox, wndProc.Checkbox );
SetDlgItemText( id, nullptr );
CRect rc=GetDlgItemClientRect(id);
rc.left=16; //TODO: replace by real margin from left edge
const HWND hHyperlink=::CreateWindowW(
WC_LINK, hyperlinkControlText, WS_CHILD|WS_VISIBLE,
rc.left, rc.top, rc.Width(), rc.Height(), hStdCheckbox, (HMENU)idHyperlinkControl, 0, nullptr
);
SetDlgItemUserData( id, hHyperlink );
::SendMessageW( hHyperlink, WM_SETFONT, (WPARAM)GetFont()->m_hObject, 0 );
}

void CRideDialog::ConvertToCommandLikeButton(HWND hStdBtn,WCHAR wingdingsGlyphBeforeText,COLORREF textColor,int glyphPointSizeIncrement,COLORREF glyphColor,bool compactPath){
// converts an existing standard button to a "command-like" one known from Windows Vista, featuring specified GlypfBeforeText ('\0' = no Glyph)
::SetWindowLong( hStdBtn, GWL_STYLE, ::GetWindowLong(hStdBtn,GWL_STYLE)|BS_OWNERDRAW );
Expand Down
1 change: 1 addition & 0 deletions Main/src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ namespace Utils{
void SetDlgItemSingleCharUsingFont(WORD id,WCHAR singleChar,LPCTSTR fontFace,int fontPointSize) const;
void PopulateDlgComboBoxWithSequenceOfNumbers(WORD cbId,BYTE iStartValue,LPCTSTR strStartValueDesc,BYTE iEndValue,LPCTSTR strEndValueDesc) const;
void ConvertDlgButtonToSplitButton(WORD id,PCSplitButtonAction pAction,BYTE nActions) const;
void ConvertDlgCheckboxToHyperlink(WORD id,WORD idHyperlinkControl,LPCWSTR hyperlinkControlText) const;
bool GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,int nIntsMin=0,int nIntsMax=INT_MAX) const;
void SetDlgItemIntList(WORD id,const CIntList &list) const;
};
Expand Down
1 change: 1 addition & 0 deletions Main/src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#undef min
#undef max
#undef INFINITY
#undef SubclassWindow

#if _MSC_VER<=1600
#define constexpr const
Expand Down

0 comments on commit 09bac02

Please sign in to comment.