|
is there a function which can change hex string to int value?
atoi() can chage dec string to int value,
i.e. atoi("12") is int 12.
which function can change hex string, such as "AF" and "1D" to int value 0xAF and 0x1D?
includeh10
|
|
|
|
|
strtol("15AF", NULL, 16); //this uses base 16 and returns a long. the "NULL" in the middle returns the location of where it stopped parsing if you give it a valid pointer instead of NULL.
-- Rocky Dean Pulley
|
|
|
|
|
How a number is stored internally and how it is represented in code are two different things. To convert between bases, see rocky's reply.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I'm trying to figure out how to get the Device Context for a Direct3D 8.0 Backbuffer so that I can run a few GDI calls to the Backbuffer before Presenting it for display. There is a GetDC function supported in DirectX 9.0, but it doesn't go back to 8.0
Is there a backdoor way to get (or create) a backbuffer Device Context that won't impact rendering speed?
Thanks in advance
Bob Ciora
|
|
|
|
|
I have problems displaying an ATL Window (CDialogImpl-derived) in an ATL component that has "MFC support" enabled.
Tracing into the calls:
The Atl Dialog Box function finds a respective resource (it's looking for two, and picks one). DialogBoxIndirect does nothing, returns -1, but sets the last error to 0 (it DOES modify it! ).
The dialog class comes from a header that works in other ATL components (without MFC support). I added the resource to the project (include in the resource file).
Any ideas?
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I know there is a reasonable explination behind what is going on here, but I can't figure it out.
I create a pointer, pass it into a method and when the method returns, the value of the pointer is NULL. If I trace the method call, there is a valid pointer all the way until GetNextApproach returns.
Any ideas?
CApproach* approach = NULL;
GetNextApproach(approach);
// approach is NULL here
-Kevin Shaffer
kshaff03@yahoo.com
|
|
|
|
|
That's how function parameters work. Any changes that GetNextApproach() makes to its parameter are not reflected in the caller. Make the parameter a reference (CApproach*& ) to have the caller see the change.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
try something like :
GetNextApproach( CApproach** p)<br />
{<br />
*p = new CApproach;<br />
}<br />
<br />
CApproach* approach = NULL;<br />
GetNextApproach(&approach);
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Why should it not be null? That's what you set it at. Passing the address of the pointer can make it modify it but just passing the pointer itself won't modify it. Let me explain.
See the code and the two functions below. Since you are not giving the address of the pointer to the first one, the pointer is not changing from null, it is only valid inside of your function.
char *sz = NULL;
func1(sz);
//sz is still null here.
func2(&sz);
//ok now sz is changed.
func1(char *sz)
{
sz = new char[1024];
strcpy(sz, "blah");
}
func2(char **sz)
{
*sz = new char[1024];
strcpy(*sz, "blah");
}
This is probably what you want your code to do:
CApproach approach; //notice, not a pointer.
GetNextApproach(&approach);
-- Rocky Dean Pulley
|
|
|
|
|
Ok, I think I am understanding now.
This is valid because the function is changing the contents of where the pointer I am passing in points to, not the actual value of the pointer itself.
char g_code[APP_AIRPORT_CODE_SIZE + 1];
GetCode(g_code);
GetCode(char* code)
{
strcpy(code, "Code");
}
However this does not work as I expected because I am trying to change the actual value of the pointer g_code:
char* g_code;
GetCode(g_code)
{
g_code = GetPointerToArraysomeOtherPlace();
}
Please let me know if I am still in la la land.
Thank you for your answers.
Kevin Shaffer
kshaff03@msn.com
|
|
|
|
|
rocky_pulley wrote:
This is probably what you want your code to do:
CApproach approach; //notice, not a pointer.
GetNextApproach(&approach);
Yes, except I don't want to make a copy, I just want to reference an object that is already created.
I also want to know, if I did the following, this would create a memory leak, right?
CApproach approach;
GetNextApproach(&approach);
GetNextApproach(CApproach* approach)
{
approach = GetAddressOfApproachSomePlaceElse();
}
Kevin Shaffer
kshaff03@msn.com
|
|
|
|
|
it's not a copy, he passing approach by reference.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
If, GetAddressOfApproachSomePlaceElse() calls new, then yes, this would be a memory leak. If in your function you want to change what object a pointer points to (not the object itself, but what object it points to), then one technique is to pass it a pointer to a pointer.
CApproach* pApproach = NULL;
GetNextApproach(&pApproach)
void GetNextApproach(CApproach** ppApproach)
{
*ppApproach = GetAddressOfApproachSomePlaceElse();
}
If you simply pass it a pointer, then it makes a copy of the pointer (not a copy of the object, but a copy of the pointer to the object). Any changes you make to the pointer (not the object, but the pointer to the object) will not be kept when the function returns, they are thrown away with the copy of the pointer.
Hope this helps,
Tim
|
|
|
|
|
The correct approach would be:
CApproach* approach = GetNextApproach();
The other responses solve the problem ( not passing by reference ), but they ignore the fact that you're passing null in, all you want is for the value to be returned.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I want to include the Outlook2Ctrl in a program, but I also want to split the right side area ( which is the remaining part ) horizontally into two panes.
I used a class derived from CSplitterWnd (by Daniel Zuppinger) and it's on this site. But I couldn't do it.
I tried to split, first vertically [CView || NULL]
then using the NULL pane I splitted the right vertically. But couldn't include the Outlook2Ctrl in the CView place.
Please help me...even by a hint...even not using the upper-mentioned splitter class.
Thanks
|
|
|
|
|
It sounds like you need to create your own class that inherits directly from CView, then add the Outlook2Ctrl control to that window. When the window is resized, call MoveWindow on the outlook control to make it the same size as the view.
-- Rocky Dean Pulley
|
|
|
|
|
The author of the Outlook2Ctrl had written "the outbar docks normally on the left side of the main frame", and in his demo, he included the Control in the MainFrame directly. So I am not sure, probably this control was meant to use some properties of the CFrameWnd class.
I didn't sail into the class itself (Outlook2Ctrl) yet, because of the lack of time. And I thought that probably someone has done what I am looking for now.
Anyway, thanks "Rocky Dean Pulley" for taking the time to reply to me. Probably I should do what you've said but with modifying COutlook2Ctrl itself also( or only).
If there is any further suggestions from anyone here, I would really appreciate it.
////////////After sometime//////////////
when I read what I have written above I noticed that I had some of the answer(it docks on the left side). So I remembered that I first tried to include the control and split the remaining to two parts horizontally....it didn't work at that time for a reason not related to it directly, I fixed that thing and continued working and trying other approaches forgetting the fact that it wasn't the real reason.
So I fooled myself at that point. Sorry for bothering.
|
|
|
|
|
Hi,
I have a requirement to hide the existing taskbar and place my own taskbar there. How can i do it? The existing taskbar's class is "Shell_TrayWnd", which is not available in mfc. Should i use "Toolbars" or "rebars". I would be of great help if someone could provide me code samples. Is there anyway by which i can change the existing taskbar apperance, like changing the font, color, font size, etc...
regards,
Jayashree
|
|
|
|
|
You may want to look for some articles on replacing explorer as the shell. Is this really what you want to do? If you want to replace the task bar you will probably want to replace the shell itself as well.
-- Rocky Dean Pulley
|
|
|
|
|
hi,
Thanks for your reply. Actually i don't want to replace explorer. I just want to restrict the user from using the normal taskbar. I can hide the existing taskbar by getting the windowhandle. Now i want to replce it with my own taskbar with restricted features. I need this because i my app runs on a TV which is of a less resolution. So i have to increase the font size, colors or may be use bitmaps. If it is possible to alter the appearance of the existing taskbar too, then i want to try that also.
regards,
Jayashree
|
|
|
|
|
The available MSDN documentation is quite clear on the proper methods for setting up a TCP/IP printer connection using the TCPMON Xcv Commands, and I have had reasonable success in this area.
I came up dry when I started looking for information on specifying the IP Port (rather than the "Printer Port") that will be used to send data to a given TCP/IP printer. Certain TCP/IP printers (like HP JetDirect) expose multiple IP ports and one IP address.
Advanced Google searches have returned thousands of false hits on other uses of the word "port" that I am not interested in. Combining the word "port" with the names of printer-setup APIs does not provide any more clarity. Perhaps I need to use another language in which the same word is not used to describe these completely unrelated objects.
|
|
|
|
|
I would like my SDI/CFormView application to be either minimized or maximized but not zoomed. That much I have done.
But how can I get rid of the 'X' on the menu bar that closes the application?
cs.style = WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX ;
|
|
|
|
|
I am not sure you can get rid of it if you have a minimize box. What I do in an app is gray out the box and handle the OnQueryEndSession() message.
BOOL CCommonApp::DisableClose(BOOL bDisable)<br />
{<br />
BOOL retVal = (m_pMainWnd != NULL);<br />
if ( retVal ) {<br />
CMenu* pMenu = m_pMainWnd->GetSystemMenu(FALSE);<br />
if ( pMenu ) {<br />
CMainFrame* pMainFrame = DYNAMIC_DOWNCAST(CMainFrame,m_pMainWnd);<br />
<br />
pMenu->EnableMenuItem(SC_CLOSE,MF_BYCOMMAND | bDisable ? MF_GRAYED : MF_ENABLED); <br />
<br />
}<br />
}<br />
return retVal;<br />
}
John
|
|
|
|
|
Simply get rid of WS_SYSMENU.
|
|
|
|
|
How does one create a resource dll containing only bitmaps? Is it just a normal DLL with only bitmaps in it?
My brain is a bit fuzzy at the moment.
I am the handsome one in the crowd.
|
|
|
|