2015-04-24 12:59:49 -05:00
// 6 april 2015
# include "uipriv_windows.h"
// #qo LDFLAGS: -luser32 -lkernel32 -lgdi32 -luxtheme -lmsimg32 -lcomdlg32 -lole32 -loleaut32 -loleacc -luuid
2015-05-06 17:37:21 -05:00
static void msgloop_tab ( HWND active , HWND focus , MSG * msg )
{
BOOL hasChildren ;
BOOL idm ;
// THIS BIT IS IMPORTANT: if the current tab has no children, then there will be no children left in the dialog to tab to, and IsDialogMessageW() will loop forever
hasChildren = SendMessageW ( focus , msgHasTabStops , 0 , 0 ) ;
if ( hasChildren )
tabEnterTabNavigation ( focus ) ;
idm = IsDialogMessageW ( active , msg ) ;
if ( hasChildren )
tabLeaveTabNavigation ( focus ) ;
if ( idm ! = 0 )
return ;
TranslateMessage ( msg ) ;
2015-05-25 12:46:38 -05:00
DispatchMessageW ( msg ) ;
2015-05-06 17:37:21 -05:00
}
static void msgloop_else ( MSG * msg )
2015-04-24 12:59:49 -05:00
{
TranslateMessage ( msg ) ;
2015-05-25 12:46:38 -05:00
DispatchMessageW ( msg ) ;
2015-04-24 12:59:49 -05:00
}
void uiMain ( void )
{
MSG msg ;
int res ;
HWND active , focus ;
for ( ; ; ) {
SetLastError ( 0 ) ;
res = GetMessageW ( & msg , NULL , 0 , 0 ) ;
if ( res < 0 )
logLastError ( " error calling GetMessage() in uiMain() " ) ;
if ( res = = 0 ) // WM_QUIT
break ;
active = GetActiveWindow ( ) ;
if ( active = = NULL ) {
2015-05-06 17:37:21 -05:00
msgloop_else ( & msg ) ;
2015-04-24 12:59:49 -05:00
continue ;
}
// bit of logic involved here:
// we don't want dialog messages passed into Areas, so we don't call IsDialogMessageW() there
// as for Tabs, we can't have both WS_TABSTOP and WS_EX_CONTROLPARENT set at the same time, so we hotswap the two styles to get the behavior we want
focus = GetFocus ( ) ;
if ( focus ! = NULL ) {
2015-05-06 17:37:21 -05:00
switch ( windowClassOf ( focus , L " TODO Area not yet implemented " , WC_TABCONTROLW , NULL ) ) {
case 0 : // uiArea
// msgloop_area(active, focus, &msg);
2015-04-24 12:59:49 -05:00
continue ;
case 1 : // WC_TABCONTROLW
2015-05-06 17:37:21 -05:00
msgloop_tab ( active , focus , & msg ) ;
2015-04-24 12:59:49 -05:00
continue ;
}
// else fall through
2015-05-06 17:37:21 -05:00
}
2015-04-24 12:59:49 -05:00
if ( IsDialogMessage ( active , & msg ) ! = 0 )
continue ;
2015-05-06 17:37:21 -05:00
msgloop_else ( & msg ) ;
2015-04-24 12:59:49 -05:00
}
}
void uiQuit ( void )
{
PostQuitMessage ( 0 ) ;
}