Solved

MFC SIP keyboard causing a redraw - what am I missing?

Posted on 2009-07-06
9
497 Views
Last Modified: 2013-12-27
This is a Windows Mobile app.

I have a screen that has a textbox at the top. The text box is for typing search strings. Through the SETFOCUS and KILLFOCUS events, I have implemented a "zoom" feature. When the user clicks in the box or otherwise starts typing while on this screen, the box zooms to triple size/font, and then returns to original size when user clicks out of the edit box or another event happens that causes the edit to lose focus.

Everything works well, except for one case: toggling the SIP keyboard causes the edit to be redrawn and it is redrawing with the original dimensions rather than the zoomed dimensions. When this happens, the font is still the zoomed size, but the edit is the original size and the only way to "clear" the problem is to tap out of the editbox (to kill focus) and then tap back in.

So it is not losing focus when this happens, but apparently my way of modifying the size is missing something.


// On Focus - zooms
      CRect rc(0,0,0,0);
      searchVal.GetWindowRect(&rc);
      searchVal.SetWindowPos(NULL, 0, 0, rc.Width(), rc.Height()*2 - SCALEX(5), SWP_NOMOVE|SWP_NOZORDER);
      searchVal.SetFont(&theApp.largeFont, 1);
      searchVal.BringWindowToTop();

// Kill focus, unzooms to original
      CRect rc(0,0,0,0);
      searchVal.GetWindowRect(&rc);
      searchVal.SetWindowPos(NULL, 0, 0, rc.Width(), (rc.Height()+SCALEX(5))/2, SWP_NOMOVE|SWP_NOZORDER);
      searchVal.GetWindowRect(&rc);
      searchVal.SetFont(&theApp.smallFont, 1);


Can anyone spot what I am missing?
0
Comment
Question by:mrjoltcola
  • 5
  • 4
9 Comments
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787702
look into the following messages for the dialog :

        case WM_ACTIVATE:
            // Notify shell of our activate message
            SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
            break;
        case WM_SETTINGCHANGE:
            SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
            break;

when SIP is on/off, your windows receives one of those (settings change most probably). I remember overriding WM_SETTINGCHAGE [basically doing nothing there].
0
 
LVL 40

Author Comment

by:mrjoltcola
ID: 24787755
1) How can I do this with the MFC message map?

2) I don't quite follow here. The SIP activate/deactivate is triggering a component to redraw with its original dimensions, but it is not triggering a focus event. So with your suggestion, what should I do with those messages? Ignore them? Are you saying that possibly the dialog is redrawing on this event? If so, why would it use the original component dimensions.
0
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 500 total points
ID: 24787872
1) ON_WM_SETTINGCHANGE()
2) try to ignore this above message, I've used something like that:

void CBaseDlg::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
      if(uFlags==224) // <-- here is some experimental value = SPI_SETSIPINFO
            return;

      CWnd::OnSettingChange(uFlags,lpszSection);
}

what happens if you simply add some eg static control  to your form and give it TOOLWINDOW style (so it doesn't grab the focus from editbox) - and in the click handler call Invalidate() to the dialog?
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787919
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Author Comment

by:mrjoltcola
ID: 24787948
Ok, I am getting the general idea. So can I ask, why can't I just handle an ON_SIZE event for the component so I can draw it in its current "zoomed" state?

0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24787973
well, you could try, though I'm not sure it will work as you want, but maybe I didn't get to the bottom of the things :)
I'm not even sure you'll get WM_SIZE in such case, but this you can easily check with Spy++.
0
 
LVL 40

Author Comment

by:mrjoltcola
ID: 24788013
Ok I put the handler in for WM_SETTINGCHANGE and I did not put the if(uFlags == 224), I only overrode the handler to call the base CWnd:: handler. This solved my problem! Now when I toggle the SIP, the zoomed window keeps its position.

So first, thanks! I will close the question.

But, I surely would like to understand the root cause. What is actually happening here? I assume searchVal.SetWindowPos() is not a permanent thing, and the the ONSIZE event (is that the event?) is causing the form to redraw with original settings from the resource file?
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24788066
well, you have your controls defined in the dialog template, and God knows how MFC does a redraw :)

I think you can use Spy++ to observe what messages it receives
0
 
LVL 40

Author Closing Comment

by:mrjoltcola
ID: 31600278
I don't understand the issue fully, but this solved my problem. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now