WTL Task Bar Notifier

by Codewiz51 9. July 2011 21:37

I am putting the finishing touches on a WTL version of the MFC TaskBarNotifier class.  I'm finally getting back to C++ programming, after many months of working on several C# projects.  Here's a screen shot of the notifier window, executed as a 64 bit C++ program.  I've added a few new properties, such as transparency and degree of opacity.


I've placed the source code on my wiki.  You may download the code here.

Tags: ,


Using ADO without #import

by Codewiz51 18. April 2011 20:54

Most articles you find on the internet regarding ADO illustrate using #import to do the hardwork of importing the COM object's interface.  However, #import drags in a lot of heavy weight classes that aren't really necessary.

This article illustrates using the header files initguid.h, adoid.h and adoint.h which are included in the Windows SDK (don't worry about the version, the files have been in the SDK for as long as I can remember.) You'll need to download the SDK to use with your development environment.

#include <initguid.h>
#include <adoid.h>
#include <adoint.h>

// Sample class interface

class CSample
    // ADO Interface pointers
    // (We connect to an Access 2000 MDB file)

    CComPtr<_ADOConnection> m_pConn;
    CComPtr<_ADORecordset> m_pRecordSet;

    //More code here
    //Yada yada yada



    HRESULT hr = m_pConn.CoCreateInstance(CLSID_CADOConnection);
    if (FAILED(hr))
        ::AtlMessageBox(m_hWnd, L"CoCreateInstance failed for CLSID_CADOConnection", L"ADO Failure", MB_ICONERROR);
    else if (S_FALSE == hr)
        DWORD dwError = ::GetLastError();
        CString msgErr;
        msgErr.Format(L"CoCreateInstance(CLSID_CADOConnection)\nexperienced a non-failing error\nGetLastError returned %u", dwError);
        ::AtlMessageBox(m_hWnd, (LPCTSTR) msgErr, L"ADO Non Failing Return");

    // Create the connection object

    hr = m_pConn->Open(CComBSTR("Provider=Microsoft.Jet.OLEDB.4.0;Password=\"\";Data Source=.\\DBSAMPLE.mdb;Persist Security Info=True"));

    // Create the RecordSet object

    hr = m_pRecordSet.CoCreateInstance(CLSID_CADORecordset);

    CComVariant RSSource(L"SELECT * FROM [Network - Computers]");
    CComVariant vConn(m_pConn.p);
    hr = m_pRecordSet->put_CursorLocation(adUseClient);

    hr = m_pRecordSet->Open(RSSource, vConn, adOpenKeyset, adLockOptimistic, adCmdText);

    ADO_LONGPTR pl = 0;
    hr = m_pRecordSet->get_RecordCount(&pl);

    //More useful code here
    //Yada yada yada

And that is all there is to using the SDK header files to interface with ADO using ATL or WTL templates.

Tags: , , ,


WTL and the MS DataGrid Control

by Codewiz51 17. April 2011 18:16

This is a small departure from the ATL/WTL threading series I am writing on my wiki.  This is a framwework WTL application that utilizes the MS DataGrid Control from Service Pack 6 of Visual Studio 6.  This program provides a complete COM interface to the control, similar to what might be used in a commercial application.  I decided not to continue with this application in my article series, because you must have access to msdatgrd.ocx and its dependent controls.  However, it's chock full of interesting code that I've never seen published in one location.

I was considering using a grid called TrueDBGrid or VS Flex from ComponentOne to continue the series, but I decided to develop a pure WTL grid component so I can move to 64 bit programming without the necessity of dragging along COM.

Here's a screen shot of the WTL code utilizing msdatgrd.ocx: (The names in this grid are purely fictitious and are included in an Access 2007 example from Microsoft.)

Here's the Visual Studo 2008 project:

WTLLearningApp3-2008.7z (63.70 kb)

(You will need access to the msdatgrd.ocx control and its dependencies in order to compile this code.)

Tags: ,

Design | Programming

Home again, home again, jiggety-jog

by Codewiz51 12. April 2011 06:21

Mother goose rhymes are appropriate for this post.  I've been away from home for the last two months, working on software in San Antonio.  Being holed up in a Holiday Inn for two months sort of makes you stir crazy.  I have a lot of wiki articles ready for posting.  I spent most of my off time either working out or writing WTL applications.  (I was more successful at writing applications than working out.)

One of the surprising aspects of returning home is how long it takes to re-acclimate myself to being around family full time.  I became used to getting off work and having the rest of the day to do what I wanted, rather than working around the house and performing all the duties required of a husband and father.

So far, I've had to perform a lot of repair work on the sprinkler system.  We've been planting sod where the Bermuda grass has died from lack of sunshine.  My poor wife has been moving hoses around and watering the old fashioned way.  Having the sprinkler system back on line has made the watering job a lot less time consuming.

I've worked up an article regarding the use of OLE-COM Object Viewer as an alternative to using #import in your C++ programs: Alternative to using #import in your WTL projects.  I have authored an example WTL MSDATGRD.OCX application which illustrates using IDL instead of #import.

Oh, by the way, I have a new convection oven.  Hopefully I can post some new recipes soon.

I am happy to be home.  Like the song says, "San Antonio is nice, but it ain't home".

Tags: , ,


WTL application to encrypt a character string

by Codewiz51 16. November 2010 20:45

I took a break from DCDFLIB and the clean up of the gamma_inc_inv function.  I played around with a native C++/WTL application to encrypt and decrypt a string using the native Windows XP crypto package.

Here's a screen shot:

And here's the application.  You'll need to download the WTL macros from sourceforge.

WTLEncryptString.7z (14.41 kb)

Here's the executable, if you just want to try it out.  You'll need the V 9.0 CRT installed to run the program.

WTLEncryptString.exe.7z (34.83 kb)

Tags: , , ,



This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cats or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.

© Copyright 2008-2011