|
Hi
I´m doing some basic serial communication vith Visual C++ .NET.
Reading from the serial port with the ReadFile command:
BYTE Byte;<br />
ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0);
I have some problems displaying what I read....With the "cout" command this worked fine:
cout<<Byte;
However, with a Windows Forms Appl. I need to output the readout with
this->Textbox1->Text = Byte;
With this I get an error message, saying "cannot convert from BYTE to String"
How can I convert this BYTE variable in order to make it compatible?`
regards,
doneirik
|
|
|
|
|
Try this:
char buff[3] = "";
sprintf(buff, "%X", Byte); // Display in hex (or choose whatever format you prefer)
this->Textbox1->Text = buff;
Hope it works!
Regards
Mahendra
|
|
|
|
|
|
Hi.
First problem solved and soon I encountered the second.
So at this point my SDI program is able to open a BMP and show it on the screen. In an modal dialogue it is possible to give some borders to only show a part of the actual BMP File...
What I want to do is to save this part in a new file...
One of my books suggest just to change the two used device contexts MemDC and pDC to print from the screen in the memory...
I tried to do it this way but because of my c++ abusing I don't get it to work properly.
This is the line which prints the bmp on the screen. Width, Height, TLCx and TLCy are the variables i can manipulate to show only the important part of the picture...
pDC->BitBlt(0,0,g_Width,g_Height,pMemDC,g_TLCx,g_TLCy,SRCCOPY);
The code i plan to use is something like... make a new bitmap object and fill it with the shown bmp... to do this i use
MemDC.BitBlt(...)
Is this a possible approach for the problem or am I totally wrong ?
Best regards,
Helge.
|
|
|
|
|
Noone ever tried something similar? I am really not sure whow to solve this problem...
Would really appreciate any help...
Helge.
|
|
|
|
|
i am trying to design a client-server application
the code for sending & receiving is as follows
void CSocketDlg::OnBsend()
{
int iLen,iSent;
UpdateData(TRUE);
if (m_strMessage=="")
AfxMessageBox("Please type the name of the file");
else if (m_strMessage!=" ")
{
iLen=m_strMessage.GetLength ();
iSent=m_sConnectSocket.Send (LPCTSTR(m_strMessage),iLen);
if(iSent==SOCKET_ERROR)
{
}
else
{
CFile file(m_strMessage,CFile::modeRead|CFile::typeBinary);
char s[1025];
int totalBytesRead,bytesRead,len,flag=0;
//strcpy(s,"c:\\program files\\microsoft visual studio\\my projects\\Alka.txt");
//len=strlen(s);
totalBytesRead=0;
int length=file.GetLength();
//iSent=m_sConnectSocket.Send (LPCTSTR(s),len);
flag=1;
while(totalBytesRead<=length && iSent != SOCKET_ERROR && flag==1)
{
bytesRead=file.Read(s,1024);
s[bytesRead]='\0';
totalBytesRead+=bytesRead;
//m_ctlSent.AddString (s);
iSent=m_sConnectSocket.Send (LPCTSTR(s),bytesRead);
UpdateData(FALSE);
}
}
}
}
but iam unable to design for multiple requests. application is a MFC Dialog based application
Alka Kashyap
|
|
|
|
|
Hi all:
How can I get debug information through TRACE() or other similar macro in Win32 applications?
I added TRACE() in the source code and also include the "AFX.h".In the project setting I choose the "use MFC in a static library"? But it cannot pass the compilation!
|
|
|
|
|
The nearest equivalent would be to use AllocConsole() and write any debug strings to its handle. I have used this method in the past
If you vote me down, my score will only get lower
|
|
|
|
|
Hi
Including <crtdbg.h> gives you;
_RPT0, _RPT1 .. _RPT4, _ASSERT, et al
These are the primitives of TRACE and ASSERT.
I always use it like so, for example;
_RPT1(_CRT_WARN, "## blah = '%ls'\n", sz);
HTH
Martin
|
|
|
|
|
Have you considered OutputDebugString() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Iam getting count(data type is DWORD) in milliseconds .I have to convert into Date and Time format (dd:mm:yy hours:min:sec:milliseconds) and display it in a List view.Iam unable to get a function which serves my purpose in vc++.
|
|
|
|
|
Hi
Have a look at the COleDateTime class
Martin
|
|
|
|
|
Unless this count is the number of milliseconds that have elapsed since a certain period of time, what you are after does not exist. Otherwise, have a look at FileTimeToLocalFileTime() , FileTimeToSystemTime() , LocalFileTimeToFileTime() , et al.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi all,
I got a problem when I use NetUserGetInfo(...), can anyone help me?
There's a Domain and a WorkGroup in LAN, a client in Domain wants to get user info from a server in WorkGroup by NetUserGetInfo(). The client loged in with Domain user ID:"MyName".
When I call NetUserGetInfo, the following cases appear:
Server also has a Local user id: "MyName", but its psw diff from Domain user "MyName":
NetUserGetInfo fail!
Server also has a Local user id: "MyName", and its psw is same with Domain user "MyName":
NetUserGetInfo success!
Server does not have Local user named "MyName":
NetUserGetInfo success!
I'm wondering that how does these take place. Will a domain user ID and a same ID in a workgroup cause any trouble?
thanks a lot.
|
|
|
|
|
I am creating a 2x2 spllitter window in a SDI application.
// OnCreateClient of SDI Frame Window
...
VERIFY(m_wndSplitter.CreateStatic(this, m_rows, m_cols));
...
I want every pane to be of the same size (plus-minus 1 pixel). In
OnSize I do something like:
// OnSize of Frame Window
...
m_wndSplitter.GetClientRect(rect);
int row_height = rect.Height();
int col_width = rect.Width();
row_height /= 2;
col_width /= 2;
m_wndSplitter.SetRowInfo(0, row_height, 100);
m_wndSplitter.SetRowInfo(1, row_height, 100);
m_wndSplitter.SetColumnInfo(0, col_width, 100);
m_wndSplitter.SetColumnInfo(1, col_width, 100);
m_wndSplitter.RecalcLayout();
...
HOWEVER probably due to the "splitting margin" or border
between panes, the pane(0, 0) is larger than the other panes
with a difference of about 11 pixels in size. Other than
"manually" accounting for the border thickness, is there
a better way of making the panes same size.
Thanks in anticipation.
|
|
|
|
|
There is no way for a frame to get its splitters internal dimensions.
But you could write a new class inheriting from CSplitterWnd, and
use that instead...
Be warned, this not debugged (or even compiled code), so check it out
yourself. If omitted *loads* of error checks.
class CSymetricalSplitter : public CSplitterWnd
{
public:
BOOL ArrangeSymmetrically (int nMinX, int nMinY)
{
CRect rcClient;
GetClientRect (&rcClient);
int nCols, nRows, nSize, n;
nCols = GetColumnCount ();
nRows = GetRowCount ();
if (!nRows || !nCount)
return FALSE;
nSize = rcClient.Height ();
nSize -= (nRows - 1) * m_cySplitterGap;
nSize /= nRows;
for (n = 0; n < nRows; n++)
SetRowInfo (n, nSize, nMinY);
....
RecalcLayout ();
}
};
Hopefully that should help!
Iain.
|
|
|
|
|
Thanks. This is probably the only way out. Here is a fragment from
Q & A: C++ (Periodicals 1998) from MSDN Library 1999 that does something
similar:
After calculating the heights of the toolbars, the next troublesome task is calculating the height and width of all the splitter window components: the border with which it surrounds each pane and the splitter bar itself. All these magic numbers are contained within data members in CSplitterWnd, but naturally the data is protected, which means you can’t access it! Sigh. So what do you do? Simple: just derive a new class with public functions to export the protected data, and use it instead of CSplitterWnd in your main frame.
class CMySplitterWnd : public CSplitterWnd {
public:
CSize GetBorderSize()
{ return CSize(m_cxBorder,m_cyBorder); }
CSize GetSplitterSize()
{ return CSize(m_cxSplitter,m_cySplitter); }
};
|
|
|
|
|
(To be complete) this is what can be done:
CRect rect;
m_wndSplitter.GetClientRect(rect);
CSize splitter_size = m_wndSplitter.GetSplitterSize();
CSize border_size = m_wndSplitter.GetBorderSize();
int row_height = rect.Height() - ((splitter_size.cy * (m_rows - 1)) + (border_size.cy * 2));
int col_width = rect.Width() - ((splitter_size.cx * (m_cols - 1)) + (border_size.cx * 2));
row_height /= m_rows;
col_width /= m_cols;
for (int i = 0; i < m_rows; i++) {
m_wndSplitter.SetRowInfo(i, row_height, 100);
}
for (int j = 0; j < m_cols; j++) {
m_wndSplitter.SetColumnInfo(j, col_width, 100);
}
m_wndSplitter.RecalcLayout();
Regards
Mahendra
|
|
|
|
|
I have added a new ATL class in the project but now I want to remove this class from the project. How can I remove the class because If I remove the class manually then i need to remove other settings of the class also as it is an ATL class so it must be having enteries in the coclasses of the project.
Thanks in advance for ur help
Rits
|
|
|
|
|
Hm, not so easy work.
1st - remove the class .h and .cpp files (and delete/rename on HDD)
Then you'll have probably corresponding .rgs file in the project tree.
Then you need to remove corresponding parts in the projects .idl file - these should be probably the interface declaration IYourClass somewhere on the beginning of the .idl file. Then remove the coclass definition from .idl (should be somewhere at the end of the file).
Then last thing should be the OBJECT_ENTRY macro in the yourProject.cpp file.
Then rebuild the project and compiler will remind you about missed includes or macros.
|
|
|
|
|
Yes, u r right
I had to remove entries from the idl file also.
Thanks
Rits
|
|
|
|
|
Hi,
I'm not sure but i think that removing "class.h" and "class.cpp" files from the project will do the job.
Regards,
Eli
|
|
|
|
|
Hello,
How can I find out what program is running my program
by OpenWith... Dialog?
For example a user right-clicks on a file and chooses OpenWith...
and then my program.What is the address?How can my program knows
the address?
Please help me on this...
Thanks.
|
|
|
|
|
I'm not exactly sure what you are asking, but does AssocQueryString() or FindExecutable() help?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi All,
I' m writing a Visual C++ MFC dialog-based program. I added a Menu bar uisng Insert->Resource-> Menu, not by writing code. Then, I tried to show and hide the Menu bar of a modal dialog dynamically but didn't succeed? Could anyone kindly help me?
Cheers,
hmc
|
|
|
|
|