|
Hi,
I am trying to convert a small piece of c++ code to c# however I am not familiar with c++.
I have a BSTR called sToChange, and an unsigned int called i
the string sToChange is "ZYX123".
in c++ when i is set to sToEncode[0] (which is 90, the char code for Z) it equals 12:
i = sToEncode[0]
//i now equals 12
in c# the same code i equals 90.
What is happening in the c++ code?
Thanks,
John
|
|
|
|
|
90 is ASCII for 'Z'.
IIRC, BSTR's are unicode, right? And they don't necessarily map one to one on ASCII. Have you tried converting the BSTR to a char*? It may also be the case that your BSTR string does not contain what you think it contains.
Do a CString str; str.Format("%S", bstrString); and check the contents of str. I'm assuming you are using MFC or ATL7. If you're using ATL7, try ATLTRACE("%S\n", bstrString); to see what the string contains. And if you're not using MFC, ATL nor ATL7, then use WideCharToMultiByte to convert the BSTR to char*.
--
Please state the nature of your medical emergency.
|
|
|
|
|
I am sending a command out my serial port and waiting for a reply. All replies end with '\r'. I am using WaitCommEvent() with EV_RXFLAG as the event, to wait for a '\r' received.
But with the serial port receive queue, if a '\r' has already been received and is in the queue before I call WaitCommEvent(), will it still return that the event has happened? Or will it timeout? Anyone know?
Thanks,
dan.
|
|
|
|
|
I'd say the event will be triggered for buffered characters --otherwise the function is nearly unusable in non-overlapped mode. To make sure, try the following:- Issue the command.
- Wait for a sufficiently long time (say 10 sec.) with
Sleep to make sure the '\r' has been received by the time Sleep returns.
- Call
WaitCommEvent and see what happens. If WaitCommEvent works the bad way (it doesn't set the event), come back here and we'll try to search for a solution.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
I'm trying to plot a non linear graph using MSChart. I set up the array and val stores the result of the calculation. However, the graph I plot appears linear and it's plotted val vs val whereas I want index[0] vs val?
double val=0;
double step=0.5;
DWORD numElements[] = {10, 2}
saRet.Create(VT_VARIANT, 2, numElements);
long index[2];
for(index[0]=0; index[0]<10; index[0]++) {
for(index[1]=0; index[1]<2; index[1]++) {
val = index[0]*index[0];
saRet.PutElement(index, COleVariant( val ));
val += step;
}
}
m_chart.SetChartData(saRet.Detach());
m_chart.Refresh();
}
Any ideas?
Cheers
|
|
|
|
|
i have an SDI Application with a single view and i need to create new view, that would be a tool modeless window. what should i do?
|
|
|
|
|
An easy solution would be a simple dialog box. Another solution is to create a new window and then show and/or hide it.
Kuphryn
|
|
|
|
|
Is there a way of checking what versions of controls I am using in my application so I know what to distribute? I selected controls from the toolbox but am not sure which ones they are on my hard disk.
Hopefully, there is something like depends.exe which shows you the control name, location, version, etc. for everything your application is using.
Meanwhile, I have been looking up the CLSIDs in the header file and searching the registry and using OLE/COM object viewer to correlate the files needed.
The reason I'm asking is that even though I have packaged the rich text control, Richtx32.OCX, into my installation program and have registered the control, I am still having problems with my application's release build -- the rich edit control is not visible. I am running Windows 2000 and have tried running the program on Win98 and NT4 but no success.
Are there any other files I need with the richtext control, the flexgrid control, and the tab control besides their OCX counterparts? BTW, I'm a little confused here, I thought I selected a rich edit control (Edit box) into my form view but the CLSID is coming up with RichTx32.ocx.
|
|
|
|
|
Have you called AfxInitRichEdit at the beginning of your app?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes. Thank you. I've gotten further.
Does anyone know if there are some incompatabilities or limitations with the tab control, flex grid control, or rich text control with Win98 or other OS's???
|
|
|
|
|
I think my question was answered today. Someone asked about some problem he/she was having with the MSFlexgrid control and somebody responded that he needed a runtime license for it.
|
|
|
|
|
Hi,
I am trying to use ADO and ADOX, and I have included the following #import statements in the stdafx.h file,
#pragma warning(push)
#pragma warning(disable:4146)
#import "C:\Program Files\Common Files\System\ADO\MSADO15.dll" \
rename ("EOF", "EndOfFile")
#import "C:\Program Files\Common Files\System\ADO\msadox.dll"
#pragma warning(pop)
But, when I use the various objects in both the ADO and ADOX package, I need specify ADODB:: and ADOX:: respectively. If I do not specify this then it gives me an error saying that the class is not defined. Can Some one let me know why I am getting such an error.
Thanks,
Arthi
|
|
|
|
|
Having to prefix the names from these libraries is not a bad thing per se, but if you want to get rid of this obligation, include the following just after the the imports:
using namespace ADODB;
using namespace ADOX; This will pose problems if there are coincident names in the libraries: in those cases, you will have to include the prefix anyway.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
http://www.codeproject.com/shell/ShellExtGuide1/ShellExtGuide1_demo.zip
This is its demo project.
Aint there the code u wanna add somewhere in this demo??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
yep, but the demo project don't work on my pc...
but I'll look anyway, was hoping for the quick way out!
|
|
|
|
|
I remember in visual basic there was a function for formatting numbers which seperated the number 1763836382 to 1,763,836,382 or 1.763.836.382 depending on the system settings. is there a function that will do that in c++, or is there just a function that will seperate them with a specified character? (i was thinking sprintf but couldn't find that specific flag for digit grouping)
Thanks in advance.
-Rune Svendsen
|
|
|
|
|
Take a look at the GetNumberFormat in the MSDN. Here's a quote:
"The GetNumberFormat function formats a number string as a number string customized for a specified locale."
So you can use regular sprintf to format the number as a string, and then format that string to the specified locale.
Chris Richardson
|
|
|
|
|
I have a Dialog application with a CTReeCtrl in it . I am buiding an Object Model using the Tree Ctrl but have an XML string associated with each node in the TreeCtrl . I can generate an XML file by traversing all the nodes in the Object Model(TreeCtrl) and just printing the associated Text for a node into a file .
I need to embedd the text information with each node in the TreeCtrl ?
How should I be going about this .
One option is that
For each node in the TreeCtrl i can generate an entry in a look up table that also contains associated text(data). This can be done by generating unique data for each node and by using the SetItemData method for a TreeView Ctrl .
I want to know if there is a better way of doing this !
Please help ( ( confused:
|
|
|
|
|
SetItemData() seems the natural way to go, since you want to associate app specific data with each tree node.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
I'm having a problem assinging discontinuous ranges to chart series.
For example the following code works if Xvaluesrange and valuesrange are continuous ranges but not if they are discontinuous:
ActiveChart.SeriesCollection(1).Xvalues = Xvaluesrange
ActiveChart.SeriesCollection(1).values = Yvaluesrange
This gives a "run-time error '1004' Unable to set the Xvalue of the Series class".
From the Excel interface it is possible to assign discontinuous ranges to chart series.
I think this is happening because the Xvalues and Yvalues properties are expecting arrays of values.
If the range I am providing is contiguous, Excel can convert it to an array of values on the fly.
I need to link the data series to the cells. I cannot use constant values neither in Xvaluesrange or YValuesrange.
I cannot use SetSourceData method because it doesn't preserve the existing chart series.
How can I assign discontinuous ranges to new chart series.
Thanks in advance,
Jose.
|
|
|
|
|
Hi
currently I'm developing an app that queries a lot of game servers at a time using UDP. I have a list of about 1000 servers and want to get their information, that's why I need to call SendTo() for every server. If I receive an answer from the server I want to add all necessary information into a CListCtrl .
What's the fastest and safest way to do that? Furthermore I want to set a timeout value (say 1500ms). If the server doesn't answer in that time I want to skip the request and go on with the next server. Currently my code is very crappy and doesn't work very well, i.e. is crashes after about 20 servers (I do not use threads).
I want it that way:
for(int i=0; i<ServerCount; i++)
{
socket.SendTo(...);
(...wait 1500msec for answer)
(next server...)
}
I have overridden my own CSocket so that a member function OnReceiveUDP is called whenever there is data that can be received.
Any suggestions?
Thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm having problems with the window generation of the following code on a Win9x system.
The window is a "child" window that contain a menu and is allowed to be anywhere on the screen, it's not contain
by the parent window. On a win9x system when the window first appears the menu is present but can not be
activated. It seems that is is just drawn and thats it. If I force a redraw the menu goes away entirely.
On a W2K system the menu appears, is active and the entire function of of the window works fine.
I must be missing something ?
Thanks in advance
Tony Teveris
<br />
int iCaptionHite = GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYFRAME);<br />
<br />
CMenu *pMenu = new CMenu;<br />
pMenu->LoadMenu(IDR_VIEW);<br />
<br />
pFW->CreateEx(WS_EX_WINDOWEDGE,<br />
AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW),0,AfxGetApp()->LoadIcon(IDI_FONTVIEW)),<br />
"My Test",<br />
WS_OVERLAPPEDWINDOW | WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME | WS_VISIBLE ,<br />
iCaptionHite, iCaptionHite, GetSystemMetrics(SM_CXSCREEN)/3, GetSystemMetrics(SM_CYSCREEN)/3, m_pOwner->GetSafeHwnd(), pMenu->GetSafeHmenu(), NULL);<br />
<br />
delete pMenu;<br />
<br />
pFW->UpdateWindow();
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Hi.
Would anyone know how to retrieve a mainframe hWND from a process handle ?
If you use openProcess to get a process handle, how can you find that process's mainframe hWND ?
|
|
|
|