|
I believe it is good idea to learn C++ and/or MFC (and, perhaps Win32) if you plan to be a programmer for hire. Large corporations don't usually adapt the cutting-edge technology until they feel threre is a business need for it or they are forced to adapt because it is the only feasible option. So, the more tools you have at your disposal; the better chances you have to keep or obtain a decent job.
|
|
|
|
|
Hallo
I'd like to change the chars printed unsing HEX.
Sample:
<br />
int nHex = 0xABCDEF;<br />
char nHexText[7];<br />
sprintf(nHexText,"%x",nHex);<br />
By now i convert as hex to string and use some macros for each char to convert.
Is there any posibility to change the symbol by just using sprintf ??
THX
Timen
|
|
|
|
|
tbrake wrote: change the symbol
I'm not sure what symbol is referring to.
tbrake wrote: now i convert as hex to string
On a side note, "hex" is not a number, it is a radix for representing the number value in some base or number system. You can view a number using any radix you desire. Whether you choose to look at it in base-2, 10, 16, 32 does not change the number.
Anyway, if possible, please clarify your question.
|
|
|
|
|
hallo
OK radix ... will look up this just after this mail..
I mean Displaying Hex as String measn unsing the symbols
0 1 2 3 4 5 6 7 8 9 A B C D E F
Now i need
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
I know this is strange but i have some old hardware - this is only able to understand these symbols no hex !!! and the second problem is i need a very fast calculation.
THX
|
|
|
|
|
Wait a minute, one an earlier thread today you stated...
tbrake wrote:
Hallo
1. Well at least it makes sence. cause i have to controll some hardware. To calculate the needed commands the shortes way is to interprete int as Hex bit shift this and the result is the needed command.
I apologize but this is making no sense. I would love to help but I've been burned by questions that didn't describe the problem correctly. I would spend my valuable time working out a solution to help out a fellow CP member only to find out later on that the problem context was different enough to warrant a totally different solution thus rendering my code snippets useless. Are you sure you need a character translation for the hex representation of a number?
|
|
|
|
|
does the solution require that you send the indivdual characters representing the number or sending the number itself?
|
|
|
|
|
I am not sure but i think i need the numeric interpretation.
The controller is a GPIB card (16 BIT connector) - to the receiver there is an initialisation string send to as char "N00,TH0,V0123456789:;<=>?\n" changing anything here will end up in errors.
...
ah i think i can do this like :
<br />
int hex = 0x2ABCDEF;<br />
cmd[0] = ((hex & 0x0F000000)>>24)+48;<br />
cmd[1] = ((hex & 0x00F00000)>>20)+48;<br />
cmd[2] = ((hex & 0x000F0000)>>16)+48;<br />
cmd[3] = ((hex & 0x0000F000)>>12)+48;<br />
...<br />
OK i try this
THX
Timen
|
|
|
|
|
a rgn, for easy, lets say a rect (10,10,100,100)
I hope all lines drawn are inside the rect with any thickness of pen.
FrameRgn works fine for the purpose on screen, but it is so ugly on printer.
My Q:
how to ensue Polygon() draws lines inside the rect with any thickness of pen?
|
|
|
|
|
Here's some code to get the wheels turning. I used a couple of different things and meshed them together.
For what it's worth...
CPen pen;
CPen* pOldPen;
LOGBRUSH logBrush;
logBrush.lbStyle=BS_SOLID;
logBrush.lbColor=RGB(255,0,0);
logBrush.lbHatch=NULL;
if (pDC->BeginPath()) { // Start defining Path
CRect rect(0,0,150,150);
pDC->Rectangle(&rect); // Define the shape for the path
if (pDC->EndPath()) { // Finish defining path
CRgn rgn;
rgn.CreateFromPath(pDC);
if (pDC->SelectClipRgn(&rgn,RGN_COPY)) { // New clipping region
for (int i=0;i<150;i+=15) {
pen.CreatePen(PS_SOLID|PS_ENDCAP_SQUARE|PS_GEOMETRIC,(i/15),&logBrush,0,NULL);
pOldPen=pDC->SelectObject(&pen);
pDC->MoveTo(CPoint(i,150));
pDC->LineTo(CPoint(i+150,0));
pDC->SelectObject(pOldPen);
pen.DeleteObject();
}
}
}
}
|
|
|
|
|
I hope nothing to be clipped.
|
|
|
|
|
includeh10 wrote: I hope nothing to be clipped.
Your first post sounded like you wanted the lines clipped. I apologize for the misunderstanding.
|
|
|
|
|
Hi again guys
a simple guestion how can i convert(assighn) a variable of type _bstr_t to string
Thanks a lot for everything so far
|
|
|
|
|
I actually know this is simple, but I forget the answer. I would repost this question in the COM forum if I was you.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
|
Cool Guide!!!!
very good has everything
thanks for showing me the way
|
|
|
|
|
Mr. Dunn already pointed you to his FAQ which is probably the best resource available on CP but just in case, here are some ways you can get it done. NOTE: These will only work if the BSTR does not contain embedded NULL's as would occur in a BYTE array. If you are sure you are dealing with null terminated strings in the BSTR like when using MSXML, these will get you by.
// Using the CString constructor
_bstr_t bstrTemp("This is a test\n");
CString sTemp1((BSTR)bstrTemp);
TRACE(sTemp1);
// For when you don't have the luxury of using the constructor
CString sTemp2;
sTemp2.Format("%s",(LPCTSTR)bstrTemp);
TRACE(sTemp2);
|
|
|
|
|
Thanks bob for the help and the info but u are right
that article Dunn gave me is more than helpful
Thanks again appreciate the help
|
|
|
|
|
antonaras wrote: Hi again guys
a simple guestion how can i convert(assighn) a variable of type _bstr_t to string
_bstr_t hi("alok");
std::string str((LPCTSTR)hi) ;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
say I have
class A
{
int a;
int b;
A(int c, int d) { a=c; b=d;}
}
and <A a=2 b=3></A> tag in Xml
how can i simply parse the xml file that i get A(2,3) in my C++ program
which technology should i use? ms xml? is it good? can someone show a short example of using ms xml to the example above?
J
-- modified at 10:25 Saturday 3rd June, 2006
|
|
|
|
|
|
|
|
Hi
I am new to vc++. I want to know what is "resources" in vc++ context.
how can this be used with vc++ program I create.
waiting for reply
|
|
|
|
|
You know I am not sure, there is so many meanings that it boarders on the ridiculous.
1) Windows programming: memory, icons, bitmap, dialog boxes, I/0, and strings.
2) C++: memory, I/O.
Oh, 1 applies to Mac programming too.
A resource is anything that you must draw on to accomplish the goal, including dependency on outside resources such as the Web.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
In a Visual C++ program, visual elements in your program (menus, dialog boxes, bitmaps, icons, and some strings) are defined in a source file with the extension .RC, which is referred to as a resource script. This file is compiled and 'linked' into your program. The term "resources" refers to these visual elements.
Software Zen: delete this;
|
|
|
|