Visual C++ Interview Preparation Guide

Refine your Visual C++ interview skills with our 10 critical questions. Our questions cover a wide range of topics in Visual C++ to ensure youre well-prepared. Whether youre new to the field or have years of experience, these questions are designed to help you succeed. Secure the free PDF to access all 10 questions and guarantee your preparation for your Visual C++ interview. This guide is crucial for enhancing your readiness and self-assurance.
Tweet Share WhatsApp

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.
Download Visual C++ PDF Read All 10 Visual C++ Questions

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.

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

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

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

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"));

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);
Download Visual C++ PDF Read All 10 Visual C++ Questions

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

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);

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);

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);

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);
}
Download Visual C++ PDF Read All 10 Visual C++ Questions