titbits from the world less travelled

Author Archive

Adding a horizontal scrollbar to CListBox in windows

Description of Listbox:

Provides the functionality of a Windows list box.
Copy

class CListBox : public CWnd

Remarks

A list box displays a list of items, such as filenames, that the user can view and select.

In a single-selection list box, the user can select only one item. In a multiple-selection list box, a range of items can be selected. When the user selects an item, it is highlighted and the list box sends a notification message to the parent window.

You can create a list box either from a dialog template or directly in your code. To create it directly, construct the CListBox object, then call the Create member function to create the Windows list-box control and attach it to the CListBox object. To use a list box in a dialog template, declare a list-box variable in your dialog box class, then use DDX_Control in your dialog box class’s DoDataExchange function to connect the member variable to the control. (this is done for you automatically when you add a control variable to your dialog box class.)

Its possible to go to the resource file and add your settings directly. See below:

LISTBOX LBS_SORT | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP

But sometimes, this wont do the work. Even though you get the vertical scrollbar automatically, somehow the horizontal scrollbar refuses to show up. We need to use TEXTMETRIC and CDC to do that. We read the length of the input and adjust the width according to that:

TEXTMETRIC vartm; //contains information about the font

The CDC object provides member functions for working with a device context, such as a display or printer, as well as members for working with a display context associated with the client area of a window.

Do all drawing through the member functions of a CDC object. The class provides member functions for device-context operations, working with drawing tools, type-safe graphics device interface (GDI) object selection, and working with colors and palettes. It also provides member functions for getting and setting drawing attributes, mapping, working with the viewport, working with the window extent, converting coordinates, working with regions, clipping, drawing lines, and drawing simple shapes, ellipses, and polygons. Member functions are also provided for drawing text, working with fonts, using printer escapes, scrolling, and playing metafiles.

//varListbox is the variable name of CListBox
//you would need to call this inside the InitDialog of listbox, so that these changes are reflected in listbox

CDC* varDC = varListbox.GetDC();

if( varDC) //check for NULL
{
varDC ->GetTextMetrics(&varTM);
size_t sizeOfHz = varTM.tmAveCharWidth * 500; //you can replace 500 with any number you want
m_varListbox.SetHorizontalExtent(sizeOfHz );
//release CDC
}

posted by admin in c++, windows and have No Comments

Step by step instructions on signing your android app [.apk] to get google maps api key

Paste this exactly to get your MD5 key:

C:\Program Files\Java\jdk1.6.0_20\bin>keytool.exe -list -alias androiddebugkey -
keystore “C:\Documents and Settings\test\.android\debug.keystore” -storepass android -keypass android

Also there is a bug in eclipse, where in you will get a greyed out map with only tiles. Use this to correct that:

The solution was to set the “Custom debug keystore” setting (empty by default) to the same value as the “Default debug keystore” in the Eclipse preferences.

Second Option:

1) Open up your project in eclipse.
2) Right click your project and click on option as shown in the picture below:

3) Follow the instructions as shown below to generate a keystore:

4) Use a MD5 tool to retrieve the MD5 signature.
5) Goto http://code.google.com/android/maps-api-signup.html to get your google maps api key.
Note: this signing works only for debug version of the app.

posted by admin in Uncategorized and have No Comments

ERROR collect2: ld returned 1 exit status

This can happen because:

1) You have declared a method in the header file, but not defined it.
2) This applies to the variables also.
3) Any symbols / slots in qt.

posted by admin in Uncategorized and have No Comments

setting up symbian s60 on windows pc – part 1

HERE is the link:

posted by admin in Uncategorized and have No Comments

Titbits on security and string manipulation in c++

Even though majority of the applications use vectors to get user input and manipulate data there are some who also user character input stream or arrays to get these kind of data. I think we shouldnt be using such kind since over herewhen we use arrays there are chances of buffer overflows.Incase we have character array c[10] and we take the user input as cin >> c.

There is well ahead chance of buffer overflow, since the user can enter any number of values.
We can avoid this one way by limiting the cin.width. But this also doesnt restrict the user input completely or the other option would be we could use string by including string header.
This way we have the size always equal or less than the user input and no memory corruption or overflow.

posted by admin in Uncategorized and have No Comments

Retrive the class names of all windows[MSDN]

Below search method will be useful when you need to find a window with no caption.

FindWindow will not work correctly in such a instance.

You can make use of the below method to do that.

//get the handle to the top window

HWND h = ::GetTopWindow(0);
while ( h)
{
TCHAR    buf[100];
::GetClassName( h, (LPTSTR)&buf, 100 );
if ( _tcscmp( buf, _T(“Youclassnametosearch”) ) == 0 )
return true;

//get the handle to the next window

h = ::GetNextWindow( h , GW_HWNDNEXT);

}
return false;

posted by admin in c++, windows and have No Comments

Installing AVIRA Antivirus Personal/Professional On Linux [Ubuntu]

Installing AntiVir (example for AntiVir Server)

For using Avira AntiVir Server/ Professional v.3 with AntiVir Guard, we
recommend and support dazuko3/dazukofs.
The installation script will also install dazuko3, if it detects the needed
build components on your system. If the installation script cannot detect a
supported linux kernel version, you can only install Avira AntiVir without
AntiVir Guard. AntiVir Guard can be easily installed later. For more details,
see See The Dazuko Kernel Module.

* Type the command:

./install
Please note the dot and slash in the command syntax. Typing the command without
this path specification, leads to another command, which is not related to
AntiVir installation process and this would result in error messages and
unwanted actions.
Press q to close the license text view.
The installation script starts. After you agree with the license terms, it will
copy the program files. The Installer can read an existing license key:

Do you agree to the license terms? [n] y
creating /usr/lib/AntiVir/guard … done
copying AV_SRV_PROF to /usr/lib/AntiVir/guard … done
copying LICENSE to /usr/lib/AntiVir/LICENSE-server … done
1) installing AntiVir Core Components (Engine, Savapi and Avupdate)
copying uninstall to /usr/lib/AntiVir/guard … done
copying etc/file_list to /usr/lib/AntiVir/guard … done
…..
Enter the path to your key file: [HBEDV.KEY]
copying HBEDV.KEY to /usr/lib/AntiVir/guard/avira.key … done
installation of AntiVir Core Components (Engine, Savapi and Avupdate) complete

After you type the path to the key file, the installer continues with
updates’ configuration:

2) Configuring updates
An internet updater is available…

Would you like to create a link in /usr/sbin for avupdate-guard? [y]

* Type y and confirm with Enter .

Then the script can create a cron task for automatic updates:

linking /usr/sbin/avupdate-guard … done
Would you like to setup Scanner update as cron task ? [y]

The update cron job uses the minute when the product was installed. If you
want another update time, you can change the entries later, in
/etc/cron.d/avira_updater

* Press Enter . You can change this setting later.

Then select the update interval (daily – d; every two hours – 2):

Please specify the interval to check.
Recommended values are daily or 2 hours.
available options: d [2]

* Enter d or 2 .

If you selected daily updates, you can specify the time of the day when the
updates should start:

The AntiVir Updater can be set to always check for updates at a particular time
of day. This is specified in a HH:MM format (where HH is the hour and MM is the
minutes). If you do not have a permanent connection, you may set it to a time
when you are usually online.
available option: HH:MM
What time should updates be done [00:15]?

* Press Enter or set another time first.

Then the installer asks if you want to check for Product updates every week:

Would you like to check for Guard updates once a week ? [n]

* Press y , if you want to create this task, or just press Enter , if you
don’t.

The next step of the installation process is installing the main program.
If no dazuko device is detected on your system, the script tries to install
dazuko:

3) installing main program
copying doc/avserver_en.pdf to /usr/lib/AntiVir/guard … done
copying bin/linux_glibc22/libdazuko3compat2.so to /usr/lib/AntiVir/guard…
done

No Dazuko device found on your system
Would you like to install dazuko now ? [y]

* Press y , if you want to install dazuko and use AntiVir Guard, then press
Enter.

Dazuko3 package is installed.

installing dazuko … Available Dazuko3-Package: ‘3.0.0-rc4′
checking for needed build components:
checking for C compiler cc … found
checking for C compiler gcc … found
checking for kernel sources … found
detecting kernel version … 2.6.18
unpacking dazuko-3.0.0-rc4_2.6.18 … done
installing dazuko-3.0.0-rc4_2.6.18 …
initiate dazukofs …
done
linking /usr/lib/AntiVir/guard/libdazuko.so to /usr/lib/AntiVir/guard/
libdazuko3compat2.so…

If the attempt to install dazuko fails, you have to compile the module
yourself. For more details, see See The Dazuko Kernel Module.

AntiVir can be installed even without dazuko, but in this case it will run
without AntiVir Guard.

The installer then reads /etc/fstab , to check the directories to be mounted as
dazukofs. If no entry is found, it asks you to enter one directory to be
scanned by the Guard:

Guard will automatically protect all directories
which are mounted upon dazukofs filesystem.
Please specify at least one directory to be protected
by Guard to add in /etc/fstab: [/home]

There are some file systems that should not be overlayed by dazukofs, since
no security gain would be achieved, but on the contrary, it could lead to
system malfunction. Examples of these file systems are sysfs (/sys), procfs
(/proc), usbfs . These file systems do not allow the creation of files
anyway, so they do not need to be protected against malware.
The special directory “/ ” (root ) should not be mounted with dazukofs,
because it may also be the root for other file systems, which likewise should
not be mounted with dazukofs.
Mounting “/ ” could also be dangerous due to the fact that there will very
likely be processes already working on files under/ before dazukofs is
mounted. This might result in undefined file states, if those files are later
accessed through the dazukofs layer.

* Type one directory, which you want to be protected on-access (for example, /
home ) and press Enter .
If you want to modify the list of protected directories, you can add or
remove entries later, by editing /etc/fstab file and remounting dazukofs.

Then the installer checks if the default quarantine directory exists:

/home/quarantine, the AVIRA Guard default quarantine directory, does not exist.
INFO: You can change the quarantine directory in /etc/avira/avguard.conf.
and /etc/avira/avscan.conf after the installation.
Would you like to create /home/quarantine ? [y]

* Type Enter , to create the directory, if necessary. You can change it later
in the configuration files.

Then the script can install a GNOME plug-in, which would allow you to add the
status icon for AntiVir Guard to the panel ( – Guard is active;  – Guard is
inactive):

Would you like to install the AVIRA Guard GNOME plugin? [n]

* Type y and press Enter , if you want to install the plug-in,
or just press Enter , if you don’t.

Then you are asked if you want to create a link to avguard and if the Updater
should be automatically activated at system start:

Would you like to create a link in /usr/sbin for avguard ?[y]
linking /usr/sbin/avguard to /usr/lib/AntiVir/guard/avguard … done
Please specify if boot scripts should be set up.
Set up boot scripts [y]:

* Confirm with Enter .

The automatic system start is configured:

setting up boot script … done
installation of AVIRA Guard complete

Then the script can install the optional plug-in for Avira Security Management
Center:

4) activate SMC support
The AntiVir Security Management Center (SMC) requires this feature.
Would you like to activate the SMC support? [y]

* If you are using Avira SMC, type y or confirm with Enter .

The plug-in is installed and the installation process is complete. You can
start AntiVir Guard, if dazuko is correctly compiled:

Would you like to start AVIRA Guard now? [y]
Starting Avira AntiVir Server…
Starting: avguard.bin

You will see a report that indicates the completion of the installation:

Installation of the following features complete:
AntiVir Core Components (Engine, Savapi and Avupdate)
AVIRA Internet Updater
AVIRA Guard
AntiVir SMC plugin

* Finally, you can start AntiVir:

/usr/lib/AntiVir/guard/avguard start

Modified binaries will not run.
For example, if binaries are prelinked: Either disable prelinking or add
/usr/lib/AntiVir/guard as an excluded prelink path in
/etc/prelink.conf

posted by admin in Uncategorized and have No Comments

error: ‘fflush’ was not declared in this scope [Ubuntu 9.10]

error: ‘fflush’ was not declared in this scope [Ubuntu 9.10]

error: ‘fopen’ was not declared in this scope [Ubuntu 9.10]

error: ‘fclose’ was not declared in this scope [Ubuntu 9.10]

Use #include<cstdio.h> to solve this issue.

This is a bug in ubuntu itself.

posted by admin in Uncategorized and have No Comments

error: ‘uintptr_t’ was not declared in this scope [Ubuntu 9.10]

include header file #include <stdint.h> to solve this issue.

This is a error in ubuntu itself.

posted by admin in Uncategorized and have No Comments

SubVersion error: 1053: not able to create a service

When trying to run a subversion or svn service, we get this error stating the service is not running, this is because of the way you create the service:

Below are the right and wrong way to create it:

WRONG WAY:

F:\Program Files\Subversion\bin>sc create svnserver binpath= “F:\Program Files\S
ubversion\bin\svnserve.exe –service -r F:\Dev Files\Repository” displayname= “S
ubversion” depend= Tcpip start= auto

RIGHT WAY:

F:\Program Files\Subversion\bin>sc create svnserver binpath= “\”F:\Program Files
\Subversion\bin\svnserve.exe\” –service -r \”F:\Dev Files\Repository\”" display
name= “Subversion” depend= Tcpip start= auto
[SC] CreateService SUCCESS

Notice the apostrophe’s when a file name is declared.

posted by admin in windows and have No Comments