|
Hi, I'm trying to create an MFC application to read and process an xml file (count elements, identify elements, etc). I'm working with vc++05 and I wanted to know if exists any class or some way to open and read an xml file. Do you have any examples or ideas?? (I'm a complete beginner in this field)
Thanks for your time!
|
|
|
|
|
Google & CodeProject search engines are you best friends, for instance see
http://www.codeproject.com/KB/XML/ce_xml.aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I would recommend TinyXml[^]. I have been using it for a while and find it easy to use.
-Saurabh
|
|
|
|
|
Hi I am using the following PreTranslateMessage and it works just fine in debug mode but the ::TranslateAccelerator fails in release. What seems to be worng here ?
BOOL CLeftTabSheet1::PreTranslateMessage(MSG* pMsg) <br />
{<br />
if (pMsg->message == WM_KEYDOWN && ((CMainFrame *)AfxGetMainWnd())!=NULL)<br />
{<br />
<br />
int nVirtKey = (int) pMsg->wParam;<br />
CString str;<br />
str.Format("%d",nVirtKey);<br />
AfxMessageBox("In - PreTranslate VirtKey=" + str);<br />
if (::TranslateAccelerator( ((CMainFrame *)AfxGetMainWnd())->m_hWnd,((CMainFrame *)AfxGetMainWnd())->m_hAccelTable,pMsg))<br />
{<br />
<br />
AfxMessageBox("Out - PreTranslate");<br />
return TRUE;<br />
<br />
}<br />
}<br />
<br />
<br />
return CPropertyPage::PreTranslateMessage(pMsg);<br />
}
sdancer75
|
|
|
|
|
Do you know about GetLastError function?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Yes I know. In release mode i get "invalid acceleration table". Its strange because i use the default acceleration table IDR_MAINFRAME that doc/view wizard creates. This works just fine in the debug mode but in release mode, the member m_hAccelTable is Null.
Anyway i didn't find any solution for that, so I created a new acceleration table and I loaded manually. In this way it works but I was curious for the problem I described above.
Regards,
George
sdancer75
|
|
|
|
|
Hi,
In my win32 application i open a working thread using _beginThread(...). This thread preforms a certain work and when it's done it has to notify the main application thread. I'm implementing this by having the working thread to post a message (that will be processed by the main thread) and commit suicide (_endthread()).
For some reason the posted messages of the working thread are not received in the other threads message proc.
Does anyone have an idea?
Thanks in advance.
Snir Yarom.
|
|
|
|
|
Maybe posting the relevant code will help.
BTW why doesn't the worker thread just return?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Here's the relevant code:
void RunAuthenticate(LPVOID pThreadId);
<br />
void MyClass::Authenticate(std::string userName, std::string password, int *balance, HWND hwnd)<br />
{<br />
m_threadNum++; <br />
HANDLE hThrd = (HANDLE)_beginthread(RunAuthenticate, 0, &m_threadNum);<br />
}<br />
void RunAuthenticate(LPVOID pThreadId)<br />
{<br />
HWND hwnd = CComManager::GetInstance()->GetCallingWnd(pThreadId);
long proc;<br />
DWORD hThread = ::GetWindowThreadProcessId(hwnd,(LPDWORD)&proc);<br />
if(hThread != NULL)<br />
::PostThreadMessage((DWORD) hThread,(UINT)THREAD_FINISHED, (WPARAM)status, NULL);<br />
}
Thanks.
|
|
|
|
|
More Clarifications:
The calling thread returns right after initializing the working thread.
The working thread should notify the main thread asynchly when his job was done.
The notification message (::PostThreadMessage(...)) isn't caught in the main thread message proc.
Thanks again.
Snir_ya
|
|
|
|
|
What is CComManager (is your?)?
Why don't you simply pass the Main Window handle to the working thread so that the latter can post a message to?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks for your reply.
1.
Yes, CComManager is mine. In my code it returns the HWND of the (login) dialog that called the working thread.
The (login) dialog was intialized by the main thread. The working thread needs to post a message to this dialog. But all the messages sent by the working thread are lost.
2.
It's a win32 application. How do i get the Main window handle?
Thanks again for your help.
Snir_ya.
|
|
|
|
|
Post the message to the main window.
When you create the main window (i.e.e inside InitInstance in the wizard-generated code), you have the great opportunity to store its handle for later use.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
If you use CreateWindow() , it will return window handle.
Check this page: Creating Win32 Applications[^]
See the point 3.
Best Regards,
Suman
|
|
|
|
|
I'm developing an animated game.
It's a Win32 app, written in C++.
For various reasons, I'm porting it to use DirectDraw interfaces.
I can't find a simple way to draw text.
I saw examples of people blitting images of text, for example to draw "Hey" they draw image of 'H' then image of 'e'...
I might draw with Windows GDI but that AFAIK this is drawing to 'windows'/'controls'/HWND , which will make the code some crazy mess.
Where's the easy way ?
|
|
|
|
|
I believe you are either going to have to use letter-bitmaps as you mention above, or resort to using GUI to draw on the DirectDraw surface. I did this a long time ago, and I am not even sure if recent versions of DirectX still support the ability to have GDI/GDI+ draw on a DD surface...
Creating a function that takes a source bitmap (of letters/numbers/symbols), a string, and a origin is not really that hard, and may work faster than you think. It might be faster than going back and forth between DX/GDI in the long run...
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
|
I managed to mix the DirectDraw and Windows GDI like this:
HDC hdc = NULL;
HRESULT result = m_lpDDSBack->GetDC(&hdc);
wchar_t text[256] = "thank god";
int x = 100;
int y = 200;
size_t length = wcslen(text);
CPTDDUtils::MyDrawText(hdc, x, y, text, length);
m_lpDDSBack->ReleaseDC(hdc);
void CPTDDUtils::MyDrawText(HDC hdc, int x, int y, LPCTSTR lpString, int stringSize)
{
HGDIOBJ hFont, hOldFont;
hFont = GetStockObject(ANSI_VAR_FONT);
if (hOldFont = SelectObject(hdc, hFont))
{
TextOut(hdc, x, y,lpString , stringSize);
SelectObject(hdc, hOldFont);
}
}
I do this after I drew the bitmaps, and before I 'flip' .
So this draws the text but in white rectangle. I don't want the white rectangle, I want this rectangle to be transparent. Also, I rather use some normal font.
Also, if this code is 'messed up', please let me know.
|
|
|
|
|
Look up the SetBkMode(...) function for setting up Transparency. Also look up the ExtTextOut(...) function, as I bet you will be moving to it soon!
You can specify your own font to use by using the CreateFont(...) and CreateFontIndirect(...) functions. Better to create the font once and reuse it.
If you want something like a multicolor font, you will need to draw the bitmaps for it yourself.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks a lot.
|
|
|
|
|
Hanan888 wrote: wchar_t wchar_t text[256] = "thank god";
Why the 256? Use this instead:
wchar_t text[] = "thank god";
Why waste 492 bytes?
Hanan888 wrote: size_t length = wcslen(text);
If the above change is made this runtime call call be changed to a compile time calculation as follows:
size_t length = sizeof(text)/sizeof(text[0]) - 1;
Steve
|
|
|
|
|
|
Hi,
Can anybody tell some information about API hooking on 64-bit. I have tried Detours Express 2.1 for 32-bit. There is Detours Professional 2.1 which supports 64-bit but it is not free. So can anybody know any other library or some references to create it.
Thanks.
|
|
|
|
|
Hello
I would like to draw in a Richedit or other control. I have tried to get a DC for the control and just change the background color to start with using
CDC *dc = m_bargraph_redit.GetDC;
dc->SetBkColor(RGB(0,255,0));
this does not work. Could somebody help me get started.
I am painting directly on to the background on my GUI to draw a bargraph this works OK until the screen resolution is changed. I would like to have the bargraph stay in the same place when the screen resolution changes.
Thank in anticipation
Desmond Mardle
|
|
|
|
|
Why do you wish to draw on top of a rich edit control? When you talk about changing the "background color" do you want to change the background color of the control or the background color of the text within the control? SetBkColor does the latter and if that didn't work that's probably because the richedit's rendering code sets it back to what it wants, which is why directly drawing on to the DC of another window is typically a bad idea.
If you want to do this then you'd have to subclass the richedit control. There are many articles here[^] that talk about customizing rich edit.
As for handling display resolution changes, see WM_DISPLAYCHANGE[^]
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|