|
dk-info wrote: Problem:I have a project where I need to interface an embedded controller to a windows application. Ultimately I need to translate input from windows controls into a stream of serial characters. This stream is interpreted by the embedded controller to do "stuff". The serial interface here may be a "real" serial port, or through a USB-Serial converter cable.
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thank you for the rapid response.
I used a portion of the code you presented to illustrate how to so simple serial output from a Win32 console application. I was able to create a Handle using this code:
#include <iostream>
#include <windows.h>
#include "serialPlay.h"
using namespace std;
int main(void)
{
HANDLE hCom;
DWORD dwRet;
hCom = ::CreateFile(
TEXT("\\\\.\\COM1"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if(hCom == INVALID_HANDLE_VALUE) {
cout << "Cannot open serial port COM1\n";
return PROGRAM_FAILURE;
} else {
WriteFile( hCom, "This is testfile", 16, &dwRet, NULL );
}
return PROGRAM_SUCCESS;
}
It compiles and runs using Visual C++ in Visual Studio 2008 Express, in a Win32 console project without error, and using another computer and Hyper Terminal set to 9600 Baud, N-8-1 it does indeed transmit the message "This is testfile".
Looking to do more, here is a followup question:
I had to replace the "_T" macro with "TEXT" to resolve a compiler error; what is the "_T" macro?
Thanks again for helping me with this question.
Cheers!
David
|
|
|
|
|
dk-info wrote: what is the "_T" macro?
It's declared in the tchar.h header.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks for the help, now another question, using only the win32 console, how do you set the com port parameters?
The code you gave is the basis for setting up serial threads (if I understand it correctly) in a windows application. I am not yet ready to try to build a windows application that can interface to a serial port, I would need an example application, tailored for Win32 that will illustrate accessing these comm resources from within the application.
I don't understand enough to solve the compiler errors when I try to piece your excellent tutorial code using the Visual Studio C++ express 2008 environment and Win32.
Would you be so kind as to give a complete example of an application that can send serial characters to a com port and receive them also?
Thanks again for the excellent tutorial,
David
|
|
|
|
|
Hello
I am developing window based web application.
I want to put restriction like ,No body can capture my application's screen with any tool .
Please suggest is it possible ?
if Yes,please suggest the way to do this.
Thanks
mahendra
|
|
|
|
|
You can't.
--
Miguel A. Vilariño
Software Developer
|
|
|
|
|
Hook the function responsible for screenshotting.
EDIT: oh sorry, I didn't notice the "web application" part of that.
modified on Tuesday, November 10, 2009 11:31 PM
|
|
|
|
|
OK,I changed idea.
Now I am creating desktop application instead of web application which needs to block print screen and screen capture. The print screen can be blocked by registering the hot key but now i am trying to find any message/method called on application when other applications try to grab pixels from its window. I am trying to do this in VC++
Is it possible?
Thanks
Mahendra
modified on Tuesday, November 10, 2009 2:10 AM
|
|
|
|
|
Hi,
any luck? I am tring to do the samething with VC++ too
cheers
|
|
|
|
|
Please check this link ,may be helpful for u.
http://www.codeguru.com/forum/showthread.php?p=1893801#post1893801
|
|
|
|
|
any luck
i am trying to do the same here ...........
cheers
|
|
|
|
|
Let me know if anybody is interested in protecting from screen captures. you can contact me at krishnapawar AT gmail DOT com.
|
|
|
|
|
|
My goal:
- display a texture that i can modify in real time (windowing the histogram)
My steps:
1) create an array that will hold my raw information with fast access so i can modify windowing, the array is declared by setting RGB values 8 bit per pixel
array<Byte> dataArray = gcnew array<Byte>(Length);
2) modify the values of the images and set it to texture
IO::MemoryStream ^fs = gcnew IO::MemoryStream(this->dataArray);
fs->Seek(0,IO::SeekOrigin::Begin);
try {
mTexture = TextureLoader::FromStream(this->device,
fs,
(int)fs->Length,
768,
640,
0,
Usage::None,
Format::R8G8B8,
Pool::Default,
Filter::None,
Filter::None,
0);
}
catch (Direct3D::InvalidDataException ^e) {
te=e->ToString();
}
fs->Close();
3) display a sprite with texture in it
mSprite->Begin(SpriteFlags::None);
mSprite->Draw(this->mTexture,
Rectangle(posx*3,posy*3, 5000,5000),
Vector3(0.0F, 0.0F, 0.0F),
Vector3(0.0F, 0.0F, 0.0F),
Color::White);
mSprite->End();
the problem is that in this step it die on execution
An unhandled exception of type 'Microsoft.DirectX.Direct3D.Direct3DXException' occurred in Microsoft.DirectX.Direct3DX.dll
Additional information: Error in the application.
Someone can help me point out the problem? thank in advance
|
|
|
|
|
Hi All,
I tried to build my project in Visual Studio 2008.
I am getting some errors related to TLH files.
I tried to open the type libraries in OLE_VIEW but the some type libraries get easily open where as some gave an error:
Could not decompile selected item
Error loading type library/DLL.
TYPE_E_CANTLOADLIBRARY($80029C4A)
Kindly help me out
|
|
|
|
|
Hi deadlyabbas,
I am having the same problem.
I was wondering if you ever found a solution.
Thanks,
Osiris
|
|
|
|
|
Hello everbody
I have small problem in Visual c++ in creating a dialogbox named as Aboutbox,
this is a second dialogbox in my application ,
when i creat the this dialogbox but the following code does not appear in the implementfile.cpp
BOOL CAbout::OnInitDialog()
Should i include myself or Is there another way to do this .
Thanks
waiting for reply.
|
|
|
|
|
yeah, just make the function yourself. not a big deal.
|
|
|
|
|
There'll be a wizard to add it or you can add in manually.
Steve
|
|
|
|
|
|
Hi,
I am trying to draw two circles, which are overlapping . My problem is that the second circle is hiding the first one partially. I want to see both circles completely. Can somebody guide me what parameter should I tweak?
afx_msg void DemoWin::OnPaint ()
{
CPaintDC dc(this);
CRect myRect; /* Define rectangle coordinates */
myRect.top = 0;
myRect.left = 0;
myRect.bottom = 200;
myRect.right = 100;
dc.Ellipse(myRect);
myRect.top = 100;
myRect.left = 50;
myRect.bottom = 200;
myRect.right = 200;
dc.Ellipse(myRect);
}
Thanks
Jacob
|
|
|
|
|
TechAvtar wrote: My problem is that the second circle is hiding the first one partially. I want to see both circles completely.
What do you mean exactly ?
You want the colors of the two circles to be merged ? For instance one circle is white and the other one is white, then the intersection should be gray ?
|
|
|
|
|
You can select a NULL brush to the device context before drawing the ellipse.
...
dc.SelectObject(GetStockObject(NULL_BRUSH));
dc.Ellipse(myRect);
...
|
|
|
|
|
Thanks .This was I looking for.
|
|
|
|
|
Hi All
I am using mysql_query for create a table in mysql.In normal it's working fine.When i put some wrong column name that mysql_query show execute.But in real condition mysql_query not execute or cursor jump into catch.Here is code
try
{
CString str;
CString ct="create table longtest(78 varchar(20));"
mysql_query(conn, ct);
}
catch(_com_error pCE)
{
str.Format(_T("\n%s Error: %ld\r\n%s\r\n%s\r\n"),
(TCHAR*)pCE.Source(),
pCE.Error(),
(TCHAR*)pCE.Description(),
(TCHAR*)pCE.ErrorMessage());
MessageBox(str4,"MySQL to MSSQL");
}
plz help me
|
|
|
|