Hello all!
I'm sorry for my bad english but this problem is exciting for someone who knows and understand the MFC and have to be corrected with your help as soon as possible
I'm working actually on the open source Project MicroSip and I want to improve the User Interface.
Let me introduce to you shortly the issue: We have a class: MicrosipDlg wich create other Dialogs, some Dialogs like Settings which appear in another Dialog. And my issue don't concern the other Dialogs. But one Dialog (the Dialer) is inside the main window
(in the next snapshot it's called CallMgt)
Here is the main window of the program:
![]()
What I want to do is when I click in this button
I want to make Disappear the Dialpad (buttons 1,2,3,4,5....+,C) and in the Same time make the MicrosipDlg Smaller.
So I make disappear the buttons in the Dialer.cpp Code with this kind of lines (in a HideDialer() Function)
//in Dialer.cpp
GetDlgItem(IDC_KEY_9)->ShowWindow(SW_HIDE);
/*and to show the buttons back I use the same in another Function (ShowDialer() function) with SW_SHOW and I Make
all the buttons come back in the dialogs.*/
This Easy and it works good :
:)
BUT now come the problems!
If I want to resize the MicrosipDlg (The Parent) I looked the .rc files and in this case we have a Dialog.rc2 which Contains these:
IDD_MICROSIP DIALOGEX 0, 0, 228, 200, 0
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_OVERLAPPEDWINDOW
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "", IDC_TAB, "SysTabControl32", 0x00000108, 0, 3, 228, 16
END
IDD_DIALER DIALOGEX 0, 0, 228, 160, 0
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
EXSTYLE WS_EX_NOINHERITLAYOUT
BEGIN
COMBOBOX IDC_NUMBER, 44, 4, 145, 30, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL
PUSHBUTTON "Video call", IDC_VIDEO_CALL, 36, 27, 23, 18, BS_ICON | WS_DISABLED
PUSHBUTTON "Call", IDC_CALL, 63, 27, 82, 18, WS_DISABLED
PUSHBUTTON "Message", IDC_MESSAGE, 148, 27, 23, 18, BS_ICON | WS_DISABLED
AUTOCHECKBOX "Expand Dialpad", IDC_BUTTON_EXPAND_DIALPAD, 174, 27, 23, 18, BS_ICON | BS_PUSHLIKE | BS_FLAT
PUSHBUTTON "Transfer", IDC_TRANSFER, 36, 27, 23, 18, BS_ICON | NOT WS_VISIBLE | WS_DISABLED
PUSHBUTTON "End call", IDC_END, 63, 27, 82, 18, NOT WS_VISIBLE
CHECKBOX "Hold", IDC_HOLD, 148, 27, 23, 18, BS_ICON | BS_PUSHLIKE | NOT WS_VISIBLE | WS_DISABLED
CTEXT "+", -1, 9, 4, 16, 8
CONTROL "Microphone level", IDC_VOLUME_INPUT, "msctls_trackbar32", WS_TABSTOP | TBS_LEFT | 0x0000021A, 9, 12, 20, 50
CTEXT "-", -1, 9, 59, 16, 8
AUTOCHECKBOX "Mute microphone", IDC_BUTTON_MUTE_INPUT, 9, 74, 16, 16, BS_ICON | BS_PUSHLIKE | BS_FLAT
CTEXT "+", -1, 204, 4, 16, 8
CONTROL "Speaker level", IDC_VOLUME_OUTPUT, "msctls_trackbar32", WS_TABSTOP | TBS_LEFT | 0x0000021A, 204, 12, 20, 50
CTEXT "-", -1, 204, 59, 16, 8
AUTOCHECKBOX "Mute speaker", IDC_BUTTON_MUTE_OUTPUT, 204, 74, 16, 16, BS_ICON | BS_PUSHLIKE | BS_FLAT
CONTROL "1", IDC_KEY_1, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 56, 54, 39, 18
CONTROL "2", IDC_KEY_2, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 99, 54, 39, 18
CONTROL "3", IDC_KEY_3, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 142, 54, 39, 18
CONTROL "4", IDC_KEY_4, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 56, 75, 39, 18
CONTROL "5", IDC_KEY_5, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 99, 75, 39, 18
CONTROL "6", IDC_KEY_6, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 142, 75, 39, 18
CONTROL "7", IDC_KEY_7, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 56, 96, 39, 18
CONTROL "8", IDC_KEY_8, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 99, 96, 39, 18
CONTROL "9", IDC_KEY_9, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 142, 96, 39, 18
CONTROL "0", IDC_KEY_0, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 99, 117, 39, 18
CONTROL "*", IDC_KEY_STAR, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 56, 117, 39, 18
CONTROL "#", IDC_KEY_GRATE, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 142, 117, 39, 18
CONTROL "+", IDC_KEY_PLUS, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 99, 138, 39, 18
CONTROL "<", IDC_DELETE, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 56, 138, 39, 18
CONTROL "C", IDC_CLEAR, "BUTTON", BS_OWNERDRAW | WS_TABSTOP, 142, 138, 39, 18
END
IN MY CASE I WANT TO MAKE THE DIALER resized with this width and height :228,90 ( so smaller height )
and the MicrosipDlg smaller and because of the taskbar (tabs..) lets say in Height :130 instead of 200.
So I looked if there is any Function that can help me doing that: and SetWindowPos and I understand now how it works!
I can resize the MicrosipDlg bigger
but NEVER smaller than the size of the
Dialer which is a tab included inside MicrosipDlg.
And the code is done in My Dialer.cpp file where I make disappear the buttons and bring them back. this is the line wher i try to make the MicrosipDlg smaller with a height of 130 (but MicrosipDlg take finally a height of 200 the Dialer's height fixed in
the .rc2 file):
microsipDlg->SetWindowPos(NULL, 0, 0, 228, 130, SWP_SHOWWINDOW | SWP_NOMOVE);
So this is where in MicrosipDlg.cpp the Dialer Dialog is created:
//this is MicrosipDlg.cpp
CTabCtrl* tab = (CTabCtrl*) GetDlgItem(IDC_TAB);
tab->SetMinTabWidth(1);
TC_ITEM tabItem;
tabItem.mask = TCIF_TEXT | TCIF_PARAM;
pageDialer = new Dialer(this);
tabItem.pszText = Translate(_T("CallMgt"));
tabItem.lParam = (LPARAM)pageDialer;
tab->InsertItem( 99, &tabItem );pageDialer->SetWindowPos(microsipDlg, 0, 32, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
AutoMove(pageDialer->m_hWnd,50,0,0,0);
______________________________________________________
//and this is the code of AutoMove function (which is in CBaseDialog.cpp file):
void CBaseDialog::AutoMove(HWND hWnd, double dXMovePct, double dYMovePct, double dXSizePct, double dYSizePct)
{
ASSERT((dXMovePct + dXSizePct) <= 100.0); // can't use more than 100% of the resize for the child
ASSERT((dYMovePct + dYSizePct) <= 100.0); // can't use more than 100% of the resize for the child
SMovingChild s;
s.m_hWnd = hWnd;
ASSERT(s.m_hWnd != NULL);
s.m_dXMoveFrac = dXMovePct / 100.0;
s.m_dYMoveFrac = dYMovePct / 100.0;
s.m_dXSizeFrac = dXSizePct/ 100.0;
s.m_dYSizeFrac = dYSizePct/ 100.0;
::GetWindowRect(s.m_hWnd, &s.m_rcInitial);
ScreenToClient(s.m_rcInitial);
m_MovingChildren.push_back(s);
}
So I tried in Dialer.cpp to Resize The Dialer with this line:
microsipDlg->pageDialer->SetWindowPos(NULL, 0, 30, 228, 100, SWP_SHOWWINDOW | SWP_NOZORDER); //this is to make it small
// and the same line with bigger height when i want the Dialer bigger with all the buttons
But it wasn't working... this is the result of it:
![]()
I tried the AutoMove Function (see in the code i put before in this post) But it's not working and the result was not good.
So if you have an idea thank you for your help
or if you want to have more informations, I can put more code here, it's an open source project and you can have the original source code here: http://www.microsip.org/source (Version
3.10.11.0)
Anyway, thanks a lot ad YOU DID IT, you read all this post (with this crappy english :) (French people have a BIG issue with English haha)
Sincerely, Ahmed