right to left - MFC query reading order (RTL) from loaded dll resource? -


we have old mfc app localized multiple languages. have language menu allows user select language (restart of app required). when rtl language such arabic selected, main window frame, , dialogs created in code via calls afxmessagebox, remain in ltr; when run on system runs windows in arabic. want set ws_ex_layoutrtl bit on windows create based on kind of resource loaded. there way use handle retrieved afxgetresourcehandle query if resources rtl? if not, there way this?

edit:

so clarify, problem main window frame, , dynamic dialogs remains in ltr layout when loaded resource dll rtl. load resource dll first thing in app initinstance function based on 3 letter code stored in registry user sets selecting language language menu drop down. resources dll work fine. have issue on main frame, , generic dialogs load such message boxes when error occurs. perhaps code snippet can explain i'm looking for:

bool cwingfmainframe::precreatewindow( createstruct& cs ) {     hinstance hinst = afxgetresourcehandle ();     if( hinst )     {         //add logic here determine if loaded resource dll rtl         cs.dwexstyle |= ws_ex_rtlreading | ws_ex_layoutrtl;     }      if( !cframewnd::precreatewindow( cs ) )     {         return false;     }      cs.style = ws_overlapped  | ws_caption  | fws_addtotitle              | ws_thickframe  | ws_sysmenu  | ws_minimizebox               | ws_maximizebox | ws_maximize;      return true; } 

if not method, there function can use determine reading order based on locale info 3 letter country code, or language id? on windows7 build following, need support windows xp :(.

int nresult = getlocaleinfo ( lcid, locale_ireadinglayout, null, 0 ); tchar* szreadinglayout = new tchar[ nresult ]; nresult = getlocaleinfo ( lcid, locale_ireadinglayout, szreadinglayout, nresult ); 

edit2:

still trying going. have following code think should work, doesn't. know dialog i'm getting handle has layoutrtl set true, , has 3 items. when following code executes dwextendstyle 0, , cdit 0, should 3. see doing wrong in code? did verify afxgetresourcehandle returning handle arabic resources.

hinstance hinst = afxgetresourcehandle (); if( hinst ) {     //make sure i'm looking @ right file.     char szpath[ max_path ];     dword result = ::getmodulefilename( hinst, szpath, max_path );     if( result )     {         atltrace( "setting resource handle %s\n", szpath );     }      // locate dialog box resource     hrsrc hres = findresource( hinst, makeintresource( idd_aboutbox ), rt_dialog );     if ( hres )     {         // load dialog box         hglobal hresload = loadresource( hinst, hres );         if ( hresload )         {             // real pointer resource             lpvoid lpreslock = lockresource( hresload );             if (lpreslock )             {                 // cast raw bits useful                 lpdlgtemplate pdlgtemplate = (lpdlgtemplate)lpreslock;                 if( pdlgtemplate )                 {                     if( pdlgtemplate->dwextendedstyle & ws_ex_rtlreading ||                          pdlgtemplate->dwextendedstyle & ws_ex_layoutrtl )                     {                         cs.dwexstyle |= ws_ex_rtlreading | ws_ex_layoutrtl;                     }                 }             }         }     } } 

in resource file dialog defined this, can't seem hands on exstyle inside code...

100 dialogex 0, 0, 257, 83, 0 style ds_setfont | ds_modalframe | ws_popupwindow | ws_dlgframe exstyle ws_ex_left | ws_ex_ltrreading | ws_ex_rightscrollbar | ws_ex_layoutrtl caption "حول جهاز التدريب على طلب المساندة في إطلاق النيران" language lang_arabic, sublang_arabicneutral font 8, "tahoma" {      icon   128, -1, 7, 8, 20, 20      defpushbutton   "موافق", 1, 178, 7, 50, 14, ws_group, ws_ex_left |  ws_ex_ltrreading | ws_ex_rightscrollbar | ws_ex_layoutrtl      ctext   "معلومات عن الإصدار", 1692, 44, 10, 130, 48, ss_noprefix, ws_ex_left |  ws_ex_ltrreading | ws_ex_rightscrollbar | ws_ex_layoutrtl } 

thanks.

well, i'm not happy it, had resort bit twiddling move on. here have works. tested english , arabic. else. cheers.

hinstance hinst = afxgetresourcehandle (); if( hinst ) {     // locate dialog box resource     hrsrc hres = findresource( hinst, makeintresource( idd_aboutbox ), rt_dialog );     if ( hres )     {         // load dialog box         hglobal hresload = loadresource( hinst, hres );         if ( hresload )         {             // real pointer resource             lpvoid lpreslock = lockresource( hresload );             if ( lpreslock )             {                 // raw bit manipulations                 byte* praw = (byte*)lpreslock;                 word signature = *(word*)( praw + sizeof( word ) );                 bool isdialogex = ( signature == 0xffff );                 if( isdialogex )                 {                     size_t offset = sizeof( word ) + sizeof( word ) + sizeof( dword );                     dword exstyle = *(dword*)( praw + offset );                     if( exstyle & ws_ex_rtlreading || exstyle & ws_ex_layoutrtl )                     {                         cs.dwexstyle |= ws_ex_rtlreading | ws_ex_layoutrtl;                     }                 }             }         }     } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -