Bug in my Win32 Program

Oct 26, 2013 at 5:22pm
Problem: Edit control does't show after document saves.

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
case ID_FILE_SAVEAS:
			{
				OPENFILENAME ofn;
				char szFileName[ MAX_PATH ] = "";
				ZeroMemory( &ofn, sizeof( ofn ) );

				ofn.lStructSize	= sizeof( ofn );
				ofn.hwndOwner	= hwnd;
				ofn.lpstrFilter	= "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
				ofn.lpstrFile	= szFileName;
				ofn.nMaxFile	= MAX_PATH;
				ofn.lpstrDefExt	= "txt";
				ofn.Flags		= OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;

				if( GetSaveFileName( &ofn ) )
				{
					HWND hEdit, hTabs;
					hTabs = GetDlgItem( hwnd, IDC_MAIN_TAB );
					int curTab = TabCtrl_GetCurSel( hTabs );
					hEdit = vect[ curTab ];

					if( SaveTextFileFromEdit( hEdit, szFileName ) )
					{
						SYSTEMTIME st;
						GetLocalTime( &st );
						char dateTime[ 27 ];

						HWND hTabs = GetDlgItem( hwnd, IDC_MAIN_TAB );
						
						char drive[ _MAX_DRIVE ];
						char dir[ _MAX_DIR ];
						char fname[ _MAX_FNAME ];
						char ext[ _MAX_EXT ];
						
						_splitpath( szFileName, drive, dir, fname, ext );
						
						titem.mask	 = TCIF_TEXT;
						titem.pszText = fname;
						
						TabCtrl_SetItem( hTabs, curTab, &titem );

						sprintf_s( dateTime, "Saved: %d/%02d/%04d %02d:%02d:%02d", st.wMonth, st.wDay, st.wYear, st.wHour, st.wMinute, st.wSecond );
						SendDlgItemMessage( hwnd, IDC_MAIN_STATUS, SB_SETTEXT, 1, ( LPARAM )dateTime );
						
						ShowWindow( hEdit, SW_SHOW );
					}
				}
			}
			break;


Any suggestions as to why its not showing? For some reason the hEdit control decides to hide. - All my edit controls are stored in a vector named vect. - Status bar updates great with the date and time it was last saved.
Last edited on Oct 26, 2013 at 5:23pm
Oct 26, 2013 at 6:05pm
If you comment this line same thing is happening ?
TabCtrl_SetItem( hTabs, curTab, &titem );
Oct 26, 2013 at 6:09pm
Yes, I've commented line by line testing it after i commented each part of the code and the error appears in the ShowWindow( hEdit, SW_SHOW ) line. Its weird too because before I had ShowWindow( vect[ curTab - 1 ], SW_SHOW ) and it worked great then I tried implementing something else into the code and now I cant seem to get it to work the way I had it. I deleted everything that I tried to implement.

Corection: It does stay visible, but the tab isnt updated with the new filename when commenting that one line: TabCtrl_SetItem( hTabs, curTab, &titem ); It also will show up when changing tabs, but for some strange reason it stays hidden once I save the file.

Update: I got rid of the TabCtrl macro and used this line:

SendMessage( hTabs, TCM_SETITEM, curTab, ( LPARAM )&titem ); and I'm getting the same result.
Last edited on Oct 26, 2013 at 6:37pm
Oct 28, 2013 at 6:30pm
Well I've figured out a solution. Right after I set the tab control item text, I hid the edit control before I showed it. For some reason that works, but I'm confused as to why, so if anybody knows why that would happen, let me know please!!!
Topic archived. No new replies allowed.