Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralVC++ abt buttons Pin
Tripura.K3-Feb-05 2:41
Tripura.K3-Feb-05 2:41 
GeneralRe: VC++ abt buttons Pin
David Crow3-Feb-05 2:51
David Crow3-Feb-05 2:51 
GeneralRe: VC++ abt buttons Pin
Ravi Bhavnani3-Feb-05 7:46
professionalRavi Bhavnani3-Feb-05 7:46 
GeneralRe: VC++ abt buttons Pin
Tripura.K3-Feb-05 22:26
Tripura.K3-Feb-05 22:26 
GeneralDriver architecture advice needed Pin
@Work3-Feb-05 1:48
@Work3-Feb-05 1:48 
GeneralRe: Driver architecture advice needed Pin
Antti Keskinen3-Feb-05 3:44
Antti Keskinen3-Feb-05 3:44 
GeneralRe: Driver architecture advice needed Pin
Geert van Horrik3-Feb-05 20:41
Geert van Horrik3-Feb-05 20:41 
GeneralRe: Driver architecture advice needed Pin
Antti Keskinen3-Feb-05 23:14
Antti Keskinen3-Feb-05 23:14 
Hello !

Ah, this explains a lot. You're writing the user-mode component that allows communication with the device. The hardware drivers are already there, so you don't need to write them.

To help you get started, decide how the user should be able to use the PLCs. What services do they require ? Must they be able to write a program for the PLC and upload it ? Should they be able to read the program from the device and need a way of illustrating (such as a schematic) which shows what the device is currently programmed to accomplish ? Drawing a diagram (UML or otherwise) helps you design a solid structure on which to build.

After these decisions, the rest is quite trivial. You should follow standard COM strategy, in which you do not provide a direct access (a handle) to the device, but an interface, through which interaction is done. This will limit the user's possibilities to those which you have previously outlined, thus eliminating the user from accidentally or purposefully misusing your device. Writing an interface is as simple as writing a pure virtual base class, deriving from this class, and implementing the methods in the derived class. Then, you create a DLL which generates the class objects for each PLC device connected, and offers a routine through which a pointer to the interface class is returned to the caller.

Using interface classes is very useful. You only need to provide the base class header file for the user, alongside with the exported DLL routines, a possible .lib file, and the actual DLL. No source code is required, because the runtime will worry about redirecting the virtual function calls to the object in which these functions are implemented. Namely, the one which the DLL creates and upkeeps.

The internal implementation of the DLL depends on how you wish to present it. Winsock makes use of window objects to handle messaging (a Windows Message is sent whenever data is sent/received or the device is connected). You don't need MFC to create window objects. Just register a WNDCLASS structure and call CreateWindow, like in a normal Win32 program.
Unless you already knew, MFC is a collection of classes which wrap standard Windows routines. For example, CWnd is class which encapsulates the creation and displaying of a Windows window object. But you don't have to rely on MFC to create the window objects. You can create them manually as well.

There are many, many websites which show you how to create Win32 window objects. MSDN is full of examples: just whip out any Hello World -example for Windows, and you'll see how it's done. The key strategy is that although your DLL creates a window object, the object itself is made to be 0 pixels in heigth and width. Thus, it is invisible to the end user, although it is still there. This is a common strategy, and it's called 'hidden message windows'.

If you feel you're in a loss with standard Windows programming, I heartly recommend investing on the Charles Peltzoid's book 'Programming Windows'. It is The Bible of every Windows programmer and a must have if you intend to write Windows programs without MFC, or wish to learn more on how Windows OS works.

-Antti Keskinen

----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"

-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
GeneralRe: Driver architecture advice needed Pin
Geert van Horrik3-Feb-05 23:23
Geert van Horrik3-Feb-05 23:23 
GeneralRe: Driver architecture advice needed Pin
Antti Keskinen3-Feb-05 23:48
Antti Keskinen3-Feb-05 23:48 
GeneralRe: Driver architecture advice needed Pin
Geert van Horrik4-Feb-05 0:01
Geert van Horrik4-Feb-05 0:01 
GeneralRe: Driver architecture advice needed Pin
Antti Keskinen4-Feb-05 1:05
Antti Keskinen4-Feb-05 1:05 
GeneralRe: Driver architecture advice needed Pin
Geert van Horrik4-Feb-05 1:15
Geert van Horrik4-Feb-05 1:15 
GeneralCharting Pin
_Tom_3-Feb-05 1:24
_Tom_3-Feb-05 1:24 
GeneralRe: Charting Pin
David Crow3-Feb-05 3:47
David Crow3-Feb-05 3:47 
GeneralRe: Charting Pin
krmed3-Feb-05 6:51
krmed3-Feb-05 6:51 
GeneralGet system properies at runtime Pin
Member 16603853-Feb-05 1:13
Member 16603853-Feb-05 1:13 
GeneralRe: Get system properies at runtime Pin
David Crow3-Feb-05 2:54
David Crow3-Feb-05 2:54 
Generalabt keyboard Pin
Anonymous3-Feb-05 1:13
Anonymous3-Feb-05 1:13 
GeneralRe: abt keyboard Pin
Mike Dimmick3-Feb-05 2:43
Mike Dimmick3-Feb-05 2:43 
QuestionChanging Source IP ? Pin
Adnan5623-Feb-05 0:56
Adnan5623-Feb-05 0:56 
AnswerRe: Changing Source IP ? Pin
Antony M Kancidrowski3-Feb-05 1:13
Antony M Kancidrowski3-Feb-05 1:13 
GeneralApply different themes to single application Pin
ledallam2-Feb-05 23:39
ledallam2-Feb-05 23:39 
GeneralRe: Apply different themes to single application Pin
Antti Keskinen3-Feb-05 4:04
Antti Keskinen3-Feb-05 4:04 
GeneralNon blocking MFC Dll Pin
lmfernandez2-Feb-05 23:38
lmfernandez2-Feb-05 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.