![]() |
| | #1 |
| Registered User Join Date: May 2002
Posts: 132
| tab control Code: // create the tab control GetClientRect(hwnd, &rect); hTC_Wnd = CreateWindowEx(0, WC_TABCONTROL, NULL, WS_VISIBLE | WS_TABSTOP | WS_BORDER | TCS_HOTTRACK, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hwnd, NULL, g_hInst, NULL); if( hTC_Wnd == NULL ) return(2); Code: case WM_SIZE: GetClientRect(hwnd, &rect); MoveWindow(hTC_Wnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, FALSE); break; If you can assist, thanks. Tyouk |
| tyouk is offline | |
| | #2 |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| Seems like tab controls with the TCS_HOTTRACK style don't like to be created with (HMENU)identifiers (return value from GetLastError called immediately after CreateWindowEx is 1401: Invalid menu handle). So, you might want to create the control without an identifier and then use SetWindowLongPtr with an nIndex value of GWL_ID(or GWLP_ID, if defined) once it's been created. I noticed it also seems to have a problem with its parentage, too, and wasn't created within the parent client area - a call to SetParent, again after the control is created fixed this. This problem, too, seems to be as a direct result of the presence of the TCS_HOTTRACK style. You may also be interested in testing for the presence of hot-tracking with SystemParametersInfo (SPI_GETHOTTRACKING) if you're not already doing so.
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. Last edited by Ken Fitlike; 01-24-2005 at 02:47 AM. Reason: correction: GWL_ID not GWL_STYLE |
| Ken Fitlike is offline | |
| | #3 |
| uh oh Join Date: Jan 2005 Location: Ontario, CA
Posts: 66
| Wow, thats a lot of things not explained in the MSDN! Now what value am I setting the call of SetWindowLongPtr(hTC_Wnd, GWL_STYLE, ???). Do I set this as TCS_HOTTRACK? cause if so I don't get why I would have to do this afterwards, when I should be able to just set that style during the CreateWindowEx call couldn't I? In which case wouldn't I call CreateWindowEx with an identifier to start with? Sorry, just need some clarification there. Now without calling the SetWindowLongPtr as stated in your last post, I am getting the following error messages. When I call SetParent(hTC_Wnd, hWnd); I get the error value from GetLastError and it's 1400: Invalid window handle. Now hTC_Wnd is the global HWND to the tab control (value returned when CreateWindowEx was called). hWnd is a global HWND set when CreateWindowEx was called to create the main window. The next error message I get is when I call SystemParametersInfo(SPI_GETHOTTRACKING, 0, &bpvParam, 0); bpvParam being a BOOL that I am passing to get the TRUE (Enabled) or FALSE (Disabled) status of the TCS_HOTTRACKING style being set. I also took the code out of my WM_CREATE message and placed it in the body of WInMain and this caused my tab control to at least resize to the full size of the window, sort of. It looks like the tab doesn't fill the entire window and so there is a chunk of the window that seems to "sink down" lower. Like there is limits to the page sizes. I know thats a lot for one post. But any clarification you can give would be of great help. Thanks, cyreon PS - totally switching names so it's the same person just different users. Edit: I even did the following to heavily check for errors during the SystemParametersInfo call: Code: // check to make sure that the TCS_HOTTRACKING style was properly set
if( !SystemParametersInfo(SPI_GETHOTTRACKING, 0, &bpvParam, 0) )
{
sprintf(error, "ERROR: SystemParametersInfo failed! (%u)", GetLastError());
MessageBox(NULL, error, "Error", MB_ICONEXCLAMATION);
}
else {
if( bpvParam == TRUE )
MessageBox(NULL, "HotTracking is not active!", "Error", MB_OK);
}
Last edited by cyreon; 01-24-2005 at 01:10 AM. |
| cyreon is offline | |
| | #4 |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| Actually, ignore that earlier nonsense I posted on account of the fact that it's largely utter balderdash. ![]() The missing style (thankyou tmouse!) is WS_CHILD and this is the beginning and end of your current code problem, ie.: Code: hTC_Wnd = CreateWindowEx(0, WC_TABCONTROL, NULL, WS_VISIBLE | WS_TABSTOP | WS_BORDER | TCS_HOTTRACK | WS_CHILD, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hwnd, NULL, g_hInst, NULL);
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. Last edited by Ken Fitlike; 01-24-2005 at 12:44 PM. Reason: that's no way to skin this cat + typo |
| Ken Fitlike is offline | |
| | #5 |
| uh oh Join Date: Jan 2005 Location: Ontario, CA
Posts: 66
| Haha, that doesn't surprise me! I've forgotten to include the WS_CHILD style so many times and it has caused me so many headaches that I really should put a big post it or something on my monitor that says "Did you forget to include the WS_CHILD style again?" just as a reminder. Okay now so I placed the WS_CHILD style into the creation of the tab control and that fixed a lot of the "look" of the interface errors. Now I have the following code in my main windows procedure: Code: case WM_NOTIFY:
lpnmhdr = (LPNMHDR)lParam;
if( lpnmhdr->code == TCN_SELCHANGE )
{
MessageBox(NULL, "Tab selection change..", "Tab Change", MB_OK);
tab = TabCtrl_GetCurSel(hTC_Wnd);
if( tab != -1 )
SwitchTabs(tab);
}
break;
Basically SwitchTabs right now is two switch statements... the first is switch(curTab) which determines which tab was selected prior to the new selection. Then a switch(newTab) which determines the new tab being selected based on the value of tab passed to the function from the WM_NOTIFY message. I can't figure out why this is returning 0 everytime. Quite annoying, and most likely a very simple problem. |
| cyreon is offline | |
| | #6 |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| You could try replacing hTC_Wnd with lpnmhdr->hwndFrom as the parameter of TabCtrl_GetCurSel. If that doesn't change things then look to your 'SwitchTabs' function and see if the problem is, in fact, there.
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. |
| Ken Fitlike is offline | |
| | #7 |
| uh oh Join Date: Jan 2005 Location: Ontario, CA
Posts: 66
| Okay I tried your suggestion, it did not work. I have already tested my values for the SwitchTabs function. It would seem that the problem lies in the TabCtrl_GetCurSel call. It seems to always return 0. If you have any other suggestions then please let me know. Btw, sorry for the late reply. I recently moved and just got my internet hooked up again. cyreon |
| cyreon is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need a little help here about MFC and Tab Control stuff... | guitarist809 | Windows Programming | 4 | 09-19-2008 10:36 AM |
| Button handler | Nephiroth | Windows Programming | 8 | 03-12-2006 06:23 AM |
| Tab order in Tab Control | Halloko | Windows Programming | 2 | 05-08-2005 11:08 PM |
| Disable a tab in control tab? | Iron Mike | Windows Programming | 1 | 07-23-2003 10:50 AM |
| Using Tab control to change between dialogs | Eado | Windows Programming | 2 | 05-15-2002 03:43 AM |