|
Hi,
I would like to communicate with the serial port in my app. I think the best way is to create a worker thread accessing the serial port and filling in a CString object (something like a buffer) with the incoming characters. It must also be possible to send chars to the connected hw.
I was looking for a class implementing serial port accesses and I got PJNaughter's one. It seems to be quite well implemented but I cannot figure out how to use it in such a working thread. Is it possible to trap messages? How can I now when I have to read on the serial port? Must it be a forever loop or can it be implemented within the Windows Messages Routing?
Please help me.
|
|
|
|
|
Hi,
I don't know exactly how the class looks like but you must have some function to notify you when an event occured.
Should be somenthing like "WaitForEvent" with some parameters (event mask and timeout).
You must wait until an event like CHAR_RECEIVED occures or timeout expires .. Something like that.
General flow is something like this:
Without handshake :
- if you don't locate this kind of function to do the job for you try this :
read the port with timeout and if char received is TIMEOU_CHAR or something like this -> you didn't receive something and try again, when first valid char occures you start to construct your message. Use this on thread and be carefully with your time out values.You should have some predifined types for TIMEOUT_CHAR.
To send is much more easier, just send it.
with handshake :
- RTS/CTS, DTR/DTS or XON/XOFF you should read the protocols first and you should find functions to acces this signals from comm port.
But the genereal flow is the same. This signals helps you to know when you can send something via serial port (if device is occupied and cannot receive will raise the CTS signal ..... ).
i hope it's helpfull for you.
|
|
|
|
|
How can I open an existing WAB file and create a new WAB file?
|
|
|
|
|
I realize that this isn't exactly on subject, but I didn't see a database forum. SQL Server 2000 is supposed to have something called Federated Databases which is supposed to spread a database out over several machines, sort of like drive striping. The number of machines is supposed to be variable on setup, and reconfigurable later. Oracle has something similar called Distributed Access, but it is supposed to work differently. Does anyone have any information about a comparison between the two and which is better for what type of operations?? Thanks for your time.
|
|
|
|
|
I realize that this isn't exactly on subject, but I didn't see a database forum. SQL Server 2000 is supposed to have something called Federated Databases which is supposed to spread a database out over several machines, sort of like drive striping. The number of machines is supposed to be variable on setup, and reconfigurable later. Oracle has something similar called Distributed Access, but it is supposed to work differently. Does anyone have any information about a comparison between the two and which is better for what type of operations?? Thanks for your time.
|
|
|
|
|
i need to wright a checkers board in mfc
|
|
|
|
|
Sounds like homework! What is it you want help with?
|
|
|
|
|
Hi, I am in a problem:
An application works just fine, but:
As soon as I extract my resources into a resource-only DLL only the dialogs with standard-controls continue to load. (Therefore it is clear, that at least the app finds its resource-DLL.)
Every dialog containing CUSTOM CONTROLS fail to load:
In CDialog::DoModal() the call to CreateDlgIndirect() returns FALSE, as a result the creation is simply stopped.
I tried this with several examples from this site, the behaviour is the same...
I assume that somehow the app must get to know there are custom controls in the DLL, but how?
Any hints??
Greetings, Martin
|
|
|
|
|
Did you call AfxSetResourceHandle() to tell the framework you are using an external resource dll?
If not, load the dll with LoadLibrary() and then pass the handle to AfxSetResourceHandle() in your InitInstance override.
If you are already doing it, I don't know what's the problem.
Cheers,
Paolo.
|
|
|
|
|
Hello Paolo,
thank you for your time.
I got this code from MSDN, which should do the job:
m_hInstDLL = ::LoadLibrary("ExtRes.dll");
if ( !m_hInstDLL )
{
return FALSE; // failed to load the localized resources
}
else
{
AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL
}
As I wrote, it works with simple elements, it only fails with custom controls and ActiveX-controls.
Must I tell the DLL that it has to use these? Or the App, that the DLL uses it? HOW???
Martin
|
|
|
|
|
Hi Martin,
I'm sorry, but I can't tell you more. I never tried to use a resource DLL.
I also saw your previous message "difference of custom controls from NT to 9x". I replied just to be sure you was using the 'recommended' method.
When I have some time, I will do an experiment.
As for now, maybe you will have better luck with more experienced programmers. I hope
Cheers,
Paolo.
|
|
|
|
|
Only a few questions:
What do you mean with "custom controls"?
I suppose you have a static control (or some other standard control) in your dialog resource that gets subclassed later in the code, so why is that dialog different from the others?
And if you create a custom control at run-time, then you should have no problems at all, right?
How are the custom controls implemented in the code?
I have no other ideas...
Paolo
|
|
|
|
|
The AfxSetResourceHandle() only sets the resources for the current module.
If the custom controls and Active-X are in another DLL, then you need to create your resource DLL as an MFC Extension DLL, then it will get added to the CDynLinkLibrary list of DLL that will be searched for additional resources.
If you visually trace through the code that loads dialog resource templates, or even the CString LoadString member function, you will see examples of this internal CDynLinkLibrary list in use.
|
|
|
|
|
CustomControl
is that icon on the tool bar of the dialog editor with the
human head on it. <g> no pun intended.
Martine I usually get this kind of promlem when I forget to Register my custom window class.
But I don't know why it does not work on win 98. is it diffrent
|
|
|
|
|
Hi there, thank you very much for your help!
You've led me to the right path.
The LoadLibrary etc. is alright, the problem was the external resource DLL in conjunction with a custom control.
I have to register the window class of the control with the WNDCLASS-structure.
One element of this is the hInst, which most of the controls (Grid, BitmapViewer etc.) fill with AfxGetInstanceHandle(), which is okay in most cases.
But: here I needed AfxGetResourceHandle(), as I have to register the control with the resource DLL!!!
I still don't know why it worked with NT, but...
Greetings, Martin ))))
|
|
|
|
|
Hi,
looking for CodeWright forum.........can any1 help?
tnx
Yaron
|
|
|
|
|
Hi Yaron,
At first glance, strange to see something about CodeWright here on this site. But this proves still a lot of people ar using this powerful and extremely adaptable editor.
In the past, I've asked the guys at StarBase (formerly known as Premia Corporation), if there was somewhere a CodeWright forum. But unfortunately, so far, it doesn't seems to exist, at least not under their 'wings'. I could have used such a forum myself also very well in the past, but I always had to find the solution myself (which is highly interesting, but sometimes also heavily time consuming... ).
Anyhow, can you more specific tell us what you're looking for? Perhaps other people, who are heavily using CodeWright, can help you.
Regards,
Geert
|
|
|
|
|
Hi Geert,
tnx a lot for your reply, happy that an other person is looking for codewright help/forums......
let me specify my problem :
I've wrote a console application using win32 API, I want to add it to codewright.
I've added an icon in the tool-bar, now what I want is , when pressing the icon , a text box will be opened, and the user will be able to type in several arguments.then I want to run my console application in output->shell window using these arguments.
I don't know how to do the above, I've tried to look in help with no success.
can you help???
tnx again,
Yaron
|
|
|
|
|
Yaron,
Here is an AppBasic Macro that will do what you want. Create a file in Codewright, paste in the code below and then save it with filename of yourfile.cwb. To use it goto app basic tab and open the file. To use it press the run button. Then goto the API command dialog and type 'ExecMyUtil' (no quotes) and hit enter. It will then prompt you for an address to ping and it will then ping that address in the shell window. Once you see it works you can modify the code to ask for the parameters you would like and then Execute the command. To use the macro from a toolbar just use the function name directly. To load the cwb file so you do not need to every time you start codewright, goto the to Tools - Appbasic Macros - Load Macros menu item and in the lower section of the dialog that appears click add and then find the cwb file you created and then just click OK, now the macro will be loaded (but will no show in the AppBasic window) and be available for your toolbar.
Chris
**start of code**
Attribute VB_Name = "ExecMyUtil"
Private Sub ExecMyUtil()
Dim FunctionToExec As String
Dim Param1 As String
Param1 = InputBox("Please enter address to ping")
If Len(Param1) = 0 Then
Exit Sub
End If
LibPreLoad "cwdosbox" 'Make sure Shell window is in place
If LibFunctionExists("DosBoxExec") Then
FunctionToExec = "DosBoxExec 'ping " & Param1 & "'"
LibFunctionExec "DosBoxCurrent" ' Make Shell tab Current
LibFunctionExec FunctionToExec
Else
MsgBox "Error Loading Shell Window"
End If
End Sub
'{{CWBASIC_LOADERINFO
' cwbAddHandler 'Private Sub ExecMyUtil()', '%F'
'}}CWBASIC_LOADERINFO
**end of code**
|
|
|
|
|
Hello,
I've written a server socket class and it is defined as a member of a dialog (dialog based app)
example:
class CPortmonDlg : public CDialog {
public:
CPortmonDlg(CWnd* pParent = NULL); ServerSocket m_serversock;
...
In ServerSocket there is a method that captures server responses. How do I perform an InsertString to a list box that is on the CPortmonDlg dialog ?
Thanks,
Tony
|
|
|
|
|
Add a member variable in your CServerSocket derived class that refers to your dialog, then use it to access the listbox.
<br />
class ServerSocket {<br />
public:<br />
CPortmonDlg* m_pDlg;<br />
...<br />
}
Initialize the pointer in your CPortmonDlg constructor or OnInitDialog (before activating the socket) this way:
<br />
CPortmonDlg::OnInitDialog()<br />
{<br />
m_serversock.m_pDlg = this;<br />
...<br />
}
Then you may use the pointer to access a member listbox, in your ServerSocket class:
<br />
m_pDlg->m_listbox.AddString();<br />
This is just a way of doing it.
Cheers,
Paolo
|
|
|
|
|
Paolo,
Much thanks, Works as you said!
Tony
|
|
|
|
|
Hi,
I have an old program (with source code) which uses DDE to communicate. Can I use a new or better technique instead of DDE?
|
|
|
|
|
OLE is an improved version of DDE and ActiveX is an improved version of OLE. OLE and ActiveX can be quite complicated but the Automation part can be surprisingly easy. You probably can convert the program to be an Automation server. I do not know what examples there are in this web site and others but I am sure there are many examples. Just look for the Automation part and generally ignore the other types of OLE and ActiveX. An Automation object is what you get when you do a VB CreateObject.
|
|
|
|
|
I have implemented the MFC CRichEditView class, which is a CRichEditCtrl wrapped in a CScrollView. MFC provides a lot of functionality for character and paragraph formatting but they fall off the edge of the earth with respect to printing---setting margins, formatting to margins, pagination, etc. I would expect that something as simple as setting page margins would be straightforward, but I have found no documentation for any of this. There is one obscure MFC sample written in C, which I found pretty useless! This has to be an intentional deletion on Microsoft's end because, what good is all the wonderful formatting functionality they provide if I can't print anything?
Does anyone have ideas about how to print the CRichEditView?
Thanks
Mike Newberry
|
|
|
|