Submit MS Application Development Questions
Interrelated Information Technology
|MS Visual Basic Questions||MS Visual C++ Questions|
|MS Operating Systems and Networks Questions||.NET Questions|
|Java Questions||Computer Applications Questions|
The Computer Education Techniques knowledge base is a service for answering questions, inclusive of the research and validation of the accuracy of information in the public domain. Citation of source documentation and examples are used to provide answers to the questions. Utilization of the information of this service and reliance on the answers, information or other materials received through this web site is done at your own risk.
MS Visual Basic
|Q||I am responsible for
maintaining Visual Basic code. Is it possible to modify the VB code to:
1 - Run a command line application.
|A||Yes, all three can be
Private Sub Button1_Click(ByVal sender
As System.Object, _
Private Sub Button2_Click(ByVal sender
As Object, _
|Q||How can a form or dialog be centered programmatically on the screen?|
|A||Use the following code snippet
in order to center a form or dialog programmatically on the screen:
Private Sub Form_Load()
|Q||How can version information be returned from the AssemblyInfo file?|
|A||Use the following VB .NET code
at run-time in order to return version information.
Function GetVersion() As
Function GetComments() As
|Q||How is text converted from lower case to upper case in VB.NET?|
Use the following code for programmatically converting text from lower to upper case.
|Q||How are Procedure Delegates created?|
|A||Delegates are used to work with the address of procedures. Sometimes it will be useful to pass the location of a procedure to other procedures. Delegates are used to display “Hello from Delegates”.|
|Q||What is anchoring and docking?|
|A||In Visual Basic, the terms
docking and anchoring are used to ensure that a control covers the whole
client area of a form.
|Q||How can the computer name and IP address be programmatically obtained?|
|A||The following code uses the
System.NET.DNS namespace to access the "computer name" and it's IP address.
Option Strict Off
|Q||What is managed code and managed data?|
|A||Managed code is the code that
is written to target the services of the CLR: Common Language Runtime. In
order to target these services, the code must provide a minimum level of
information to the runtime. All of the C#, Visual Basic .NET and J# .NET
code is managed by default.
Managed data is allocated and de-allocated by the Common Language Runtime's garbage collector. C#, Visual Basic, and J#.NET data is managed by default. C++ data can be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default; this occurs even when the /CLR switch is used. When Managed Extensions for C++ are being used, a class can be marked as managed by using the __gc keyword.
With Managed data, the memory used for instances of the class is managed by the garbage collector. The class also becomes a full participating member of the .NET Framework; a major is proper interoperability with classes written in other languages.
A managed class can only inherit from one base class.
|Q||How can an .EXE be run from a VB.NET application?|
|A||In order to run a .EXE file
from a VB.NET application, it will be necessary to import the
The following code uses is used run Notepad from a VB.NET application.
MS Visual C++
|Q||What is a buffer overrun? How can I protect my organization from buffer overruns?|
|A||Buffer overruns are a
programming mistake; they involve copying the contents of a region of memory
into another region of memory that is too small to accommodate the source
It can be extremely difficult to eliminate buffer overruns in large C/C++ code bases One approach is to limit the size of the data copied in order that it is not greater than the size of the destination buffer.
The utilization of managing technologies such as .NET and Java can significantly reduce the potential for buffer overruns. Buffer protection can be activated by turning on the /GS compiler switch. With Visual Studio, the switch can be activated from the Code Generation option page on the C/C++ tab. By default, the setting will be disabled for the Debug configuration and enabled for the Release configuration.
Code Red and Blaster worms, were the result of buffer overruns in C/C++ code.
|Q||Can a WinHelp be called from a C++ MFC program?|
|Help can be programmatically
called from anywhere in code. The most common reasons for doing this would
be to open the WinHelp Table of Contents from the help menu or to call a
general help topic from a Help button on a form. Help can also be called
The WinHelp function starts WINHLP32.EXE and passes additional data indicating the nature of the help requested by the application.
In order to use the following API calls, the
WinHelp.bas or Winhelp.cls must be attached.
|Q||What is a view? How is it different from an application?|
|A||When an application is created,
the intention will be for the users to see, view, and manipulate its
documents. The process of making up a program is to create the application
using a class derived from CWinApp and surrounding the program with a frame
either based on CFrameWnd or from one of its derived classes. This type of a
simple program is designed to show the presence of an application. In order
to assist the user with files, the program should be equipped with a
document. A document is a representation of a file and in order to present a
document to the user, an object called a view, will need to be provided.
There are several ways to present documents. In order to support these variances, the MFC provides different view-based classes. MFC provides a class named CView, for laying a foundation for those classes. Although the MFC provides various view-based classes, there is a high likelihood, that none of them would fit the particular functionality that is required to be implemented.
For this reason, the CView class is:
1 - The ancestor to the other view-based
CView is an abstract class; it cannot be declared a CView variable.
The following code will produce an error.
CView *view = new CView;
|Q||How can a window be made not movable?|
|A||This can be done by adding the handle function to the WM_WINDOWPOSCHANGING message for the window and write
void CMyDialog::OnWindowPosChanging(WINDOWPOS* pWndPos)
|Q||What is better: AfxEndThread()or return?|
|A||Our system consultants recommended avoid using AfxEndThread() function as well as ExitThread in
Win32 API). When there is a thread in some objects, the destructor will not be called for them in case of using AfxEndThread().
When the return statement is used, the compiler implicitly adds to the code the appropriate destructor calls
before the thread function really ends. Accordingly, AfxEndThread() call is not safe in terms of memory leaks when destructors for objects must be called.
Declaration of AfxEndThread():
If the decision has been made to specify thread exit code this way, the return statement will provide the thread return code.
The second parameter will need to be set to TRUE or FALSE for the member m_bAutoDelete (public) for CWndThread object.
• AfxEndThread() function.
Nor is it a good practice to use TerminateThread() API function.
|Q||How can a MFC project be created with built-in help files?|
|A||When the MFC App Wizard is used for creating a project the WinHelp support can be included for the main window as part of the automatically generated files.
In order create a new project with context sensitive help support:
1. From the Visual C++ File menu, choose New.
This will create the following:
Guidelines: 1. Since no dialog boxes are created in this process, it will be necessary to add context sensitive help support for each dialog box as it is created. 2. Once there is an initial help file and .hm file, it is usually easier to have the help author add new topics with a help authoring tool. 3. The program can still be used to generate the framework help for each build, because it will provide appropriate additional topic mapping entries.
1. Since no dialog boxes are created in this process, it will be necessary to add context sensitive help support for each dialog box as it is created.
2. Once there is an initial help file and .hm file, it is usually easier to have the help author add new topics with a help authoring tool.
3. The program can still be used to generate the framework help for each build, because it will provide appropriate additional topic mapping entries.