Visual C++ Interview Preparation Guide
Download PDF
Add New Question

VC++ Interview Questions and Answers will guide us now that Microsoft Visual C++ (MSVC) is a commercial integrated development environment (IDE) product engineered by Microsoft for the C, C++, and C++/CLI programming languages. Learn MS VC++ or get preparation for the job of Microsoft Visual C++ with the help of this VC++ Interview Questions with Answers guide

10 Visual C++ Questions and Answers:

1 :: 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.
Post Your Answer

2 :: 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.
Post Your Answer

3 :: What is command routing in VC++?

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

In MDI:
View->CDocument->CMDIChildWnd ->CMDIFrameWnd -> CWinApp.
Post Your Answer

4 :: 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"));
Post Your Answer

5 :: 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);
Post Your Answer

6 :: 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
Post Your Answer

7 :: 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);
Post Your Answer

8 :: 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);
Post Your Answer

9 :: 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);
Post Your Answer

10 :: 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);
}
Post Your Answer
Add New Question