|
C++ faqs[^]
Nibu thomas
Software Developer
|
|
|
|
|
sscanf( str, "%x" , &num ) is enough.
- NS -
|
|
|
|
|
Hey NS17 thanks a lot thats all i need
appresiate the help
|
|
|
|
|
Welcome...
- NS -
|
|
|
|
|
But what if the hex value with me is in string format?
|
|
|
|
|
Can you clarify a little more?
- NS -
|
|
|
|
|
I have tried the following code which is not working.
char str[100]="ff";
char newstr[100];
sscanf(newstr, "%x", &str);
AfxMessageBox(str);
can you please tell me what is the problem here. (
|
|
|
|
|
"%x" is used to read a hexadecimal number from a string to an integer variable.
In your code your are trying to read it to char array, not to an int or long.
If you want to show the read number then try like this:
char str[100]="ff";
char newstr[100];
int num;
sscanf(str, "%x", &num);
sprintf(newstr,"decimal = %d",num);
AfxMessageBox(newstr);
It will display 255.
- NS -
|
|
|
|
|
Thank you. Its working fine.
|
|
|
|
|
I think it's funny how everyone forgets about the easiest way to do this:
strtol()[^], that is a part of the C runtime library.
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
antonaras_marcou wrote: Do you know if there is any built in function to convert a hexadecimal number to decimal.
Just use strtol() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi all
i want a graph control that has Linear,Quadratic,Power and Exponential Curve fitting features in MFC.
Any Links or info would be appreciated....
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
Hi all,
How to make an MDI child window top most among all other children?
Thanks in advance,
Sarvan AL
|
|
|
|
|
MDIActivate(...)
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
Thanks for your reply.
It (say WND-A) need not be active. If I select other child window (say WND-B), WND-A should be top most among them and WND-B should be active.
How can we make it possible?
Sarvan AL
|
|
|
|
|
Have you tried SetWindowPos . I am a bit tentative about this but you can try.
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
I tried "SetWindowPos" in view::OnInitialUpdate, like,
GetParent()->SetWindowPos(...). It doesn't work. Even I tried WS_EX_TOPMOST in CChildFrame::PreCreateWindow.
What can we do now?
Sarvan AL
|
|
|
|
|
Sarvan AL wrote: GetParent()->SetWindowPos(...).
Why are you calling the parent's(GetParent()) SetWindowPos . You want to make this child window top most right? So call SetWindowPos for this child window. I guess it will make this child window the topmost in the parent window's child window hierarchy.
Note: I haven't checked it.
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
Even this also, doesn't give desired results.
void CMyView::OnInitialUpdate()
{
CFormView::OnInitialUpdate() ;
ResizeParentToFit() ;
SetWindowPos(&wndTopMost, 0, 0, 100, 100, SWP_NOMOVE | SWP_NOSIZE) ;
}
But I am not sure that, it is possible to make an MDI child top most. Kindly let know the properties (window styles), the CWnd derived class should have.
Sarvan AL
|
|
|
|
|
I think that using GetParent() or GetParentFrame() is better.
void CMyView::OnInitialUpdate()<br />
{<br />
CFormView::OnInitialUpdate() ;<br />
ResizeParentToFit() ;<br />
<br />
GetParentFrame()->SetWindowPos(&wndTopMost, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE) ;<br />
}
Sarvan AL wrote: But I am not sure that, it is possible to make an MDI child top most.
This could be the real problem!
|
|
|
|
|
Hi Russel and Nibu,
Still the same prob.
Let me explain the scenario briefly:
I have 7 CFormView derived views. Those should be always topmost. I should have made those windows as MODELESS DIALOGS. But I made a mistake. I need to change the entire architecture of the application. It is painful. If is there any other alternative (to make an MDI child as MODELESS DIALOG), it would be a great solution.
Kindly let me know your suggestion.
Sarvan AL
|
|
|
|
|
Is there any API that can be used to get the path of the Program files directory?
|
|
|
|
|
SHGetSpecialFolderPath .
Steve
|
|
|
|
|
<br />
TCHAR szProgramFilesFolder[MAX_PATH];<br />
if(S_OK == SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, szProgramFilesFolder))<br />
{<br />
}<br />
|
|
|
|
|
hi!
i'm using TWAIN to provide support for scanners in my program, part of what you need to do in TWAIN is to "modify the event loop". The PDF documentation for TWAIN posts the following pseudo code:
....
TW_EVENT twEvent;
TW_INT16 rc;
while (GetMessage ( (LPMSG) &msg, NULL, 0, 0) )
{
if Source is enabled
{
twEvent.pEvent = (TW_MEMREF)&msg;
twEvent.TWMessage = MSG_NULL;
rc = (*pDSM_Entry) (pAppId,
pSourceId,
DG_CONTROL,
DAT_EVENT,
MSG_PROCESSEVENT,
(TW_MEMREF)&twEvent);
// check for message from Source
switch (twEvent.TWMessage)
....
Where do I put this block in MFC? Would it be in PreTranslateMessage?
What happens is, I am able to open the TWAIN Data Source Manager, and the message box to select the scanners, there is nothing in the list, and i get the following error in wincore.cpp:
First-chance exception at 0x7c950806 in TWAINTest.exe: 0xC0000005: Access violation reading location 0xfffffffe.
and it breaks at:
// call original wndproc for default handling
if (bCallDefault)
this line--> lResult = CallWindowProc(oldWndProc, hWnd, nMsg, wParam, lParam);
(line 447 or wincore.cpp)
Any ideas?
|
|
|
|