1. How to change the Mouse Pointer Over a Button at runtime?

Assuming that you have set the button's ID as IDC_BTNSAMPLE in the resource editor :-
// You have to handle the WM_SETCURSOR message handler to do that
BOOL CTestDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (pWnd == GetDlgItem(IDC_BTNSAMPLE))
{ // To load a standard cursor
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
// To load your own custom cursor. Assuming that you have created a
// Cursor in the resource editor and named it as IDC_CURSAMPLE
::SetCursor(AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_CURSAMPLE)));
// Remember to return TRUE here return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

2. How to change the Properties of a Button at runtime?

Assuming that you have set the button's ID as IDC_BTNSAMPLE in the resource editor :-
We have to use the ModifyStyle Function to do this. The function is defined as follows :-
CButton *pBtnSample = (CButton *)GetDlgItem(IDC_BTNSAMPLE); // Make the button look like a checkbox
pBtnSample->ModifyStyle(0,BS_AUTOCHECKBOX,SWP_FRAMECHANGED); // Remove the checkbox style and make it again normal
pBtnSample->ModifyStyle(BS_AUTOCHECKBOX,0,SWP_FRAMECHANGED);

3. How to change the position of Button at runtime?

Assuming that you have set the button's ID as IDC_BTNSAMPLE in the resource editor :-
CButton *pBtnSample = (CButton *)GetDlgItem(IDC_BTNSAMPLE);
pBtnSample->SetWindowPos(0,0,0,100,100,SWP_FRAMECHANGED);

4. How to change the Size of CButton at Runtime?

CButton *btnsample = (CButton *)GetDlgItem(IDC_BUTTON1);///suppose IDC_BUTTON1 is the ID of CButton/
btnsample->SetWindowPos(0,0,0,100,100,SWP_FRAMECHANGED);

5. How to Enable and Disable CButton at runtime?

CButton *btnsample = (CButton *)GetDlgItem(IDC_BUTTON1);
btnsample->EnableWindow(FALSE); // To Disable a button
btnsample->EnableWindow(TRUE); //To Enable a Button

6. How to load an Icon on a CButton at Runtime?

CButton *btnsample = (CButton *)GetDlgItem(IDC_BUTTON1);
btnsample->ModifyStyle(0,BS_ICON,SWP_FRAMECHANGED); //change the style of CButton
HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON)); //load an Icon assuming IDI_ICON is ID of ICON
btnsample->SetIcon(hIcon);

7. How to change the Text of a CButton at Runtime?

CButton *btnsample= (CButton *)GetDlgItem(IDC_BUTTON1); //suppose IDC_BUTTON1 is the ID of CButton
btnsample->SetWindowText(_T("Lahore"));

8. What is command routing in VC++?

in SDI:
View -> Doc -> FrameWnd -> App.

In MDI:
View->CDocument->CMDIChildWnd ->CMDIFrameWnd -> CWinApp.

9. How can server communicate with more than one client?

Server can communicate with more than one client with using threading concepts there are java threads which are allocated to every client
when he logs in to server,the thread handles the client.

10. Why Array Index starts from Zero?

This boils down to the concept of Binary digits. Take an array size of 64 for example. We start from 0 and end at 63. We require 6 bits.But, if we were to start from 1 and end at 64, we would require 7 bits to store the same number, thus increasing the storage size.

Download Interview PDF