January 3, 2001

CTreeViewEdit – A class for enhanced treeview node editing

‘——————————————————-‘ The CTREEVIEWEDIT Class module” This class lets you use a regular TextBox control to’ edit a treeview node’s label. All you have to do to’ use this class is adding a TextBox control to the same’ form that hosts the TreeView control, and initialize’ an instance of the class

Determine Absolute Row Index

Often, properties and methods associated with grid controls don’t provide an absolute (relative to the actual first row and not the first displayed row) row index of current or selected rows. Sample code below provides the index of the current row, assuming the absolute first row has an index of

Use Resource File to Manage Strings for Multi-lingual Applications

By using resource file, strings used by controls or message windows can be converted to different language strings in your application. The VB 6 Resource Editor allows the addition of multi-tables for multi-lingual strings. Defined strings for corresponding language strings are usually stored in the resource file, and the correct

The #error Preprocessor Directive

During the preprocessing phase, you can report errors by using the #error preprocessor directive. For example, suppose you have a program that uses 64-bit integers. This program has to be ported to various platforms. Since C++ doesn’t define a standard 64-bit int type yet, each compiler uses a different type,

<iostream.h> or <iostream>?

Although the library was deprecated for several years, many C++ users still use it in new code instead of using the newer, standard compliant library. What are the differences between the two? First, the .h notation of standard header files was deprecated more than 5 years ago. Using deprecated features

Generating Random Float Values

To generate random floating numbers, choose a floating point number, divide it by the largest value of int type and multiply the result by the value of a function that generates random integers, say rand(): #include // for std::numeric_limits#include // for rand and srand#include // for time()using namespace std;int main(){

Using const Variables to Define the Size of an Array

C++ requires that the size of an array be a constant integral expression. However, the following code refuses to compile: // in const.hextern const int ID_LENGTH; // declaration// in const.cppconst int ID_LENGTH=1024; // definition// in main.cpp#include int main(){ char id[ID_LENGTH]; // compilation error } There are two problems with this

Controlling Floating Point Precision

You can override the default number of digits after the decimal point by calling the precision() member function of an ostream object. The following program first displays six digits after the decimal point and then changes the precision to 18 digits after the decimal point: double f = 1.0/3.0; cout

std::vector Iterators

To create an iterator of a vector, you have to use a vector specialization. In the following examples, I create two vector iterators: one for the specialization vector and another for vector. Remember that iterators are strongly-typed, you cannot use an iterator of one vector specialization with another vector specialization:

No more posts to show