|
hi all,
i want write into the file wchar_t* and want to save it as UNICODE. tmp is wchar_t* and is a xml file.
my code is:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
fclose(f);
but it shows garbage.
when i change the code to:
FILE* f = _wfopen(m_sFilespecW.c_str(),L"w");
while(*tmp)
{
fputwc(*tmp,f);
tmp++;
}
fclose(f);
it saves the file but in ANSI format. it then fails to load in other function as that function only loads unicode files.
help me i want to save it in UNICODE.
|
|
|
|
|
sandeepkavade wrote: size_t no = fwrite(tmp,sizeof(wchar_t),size,f);
What is tmp and size ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi
In the code bottom I want to create a new dialog box when a condition is provided.But it failed because all threads deadlocked.How can I create a new dialog box in a worker thread?
Thanks for your help.
UINT threading(LPVOID p)
{
CMyClass * me = (CMyClass *)p;
if(something happen)
me->threading();
return 0;
}
void CMyClass::threading()
{
CDlg *dlg = new CDlg;
dlg->Create(IDD_DIALOG2,this);
dlg->ShowWindow(SW_SHOW);
}
|
|
|
|
|
But it failed because all threads deadlocked
Why so? It is too bad. I guess your UI threrad is locked ..? So try to redesign the app logic. Never do make the UI thread wait [IOW minimize it as much as possible]. Instead, for waiting purposes do create a working thread.
It is possible to create and show a dialog from a worker thread, I do not encourage such a thing though. Put the following inside the worker thread;
CMyDlg dlg;
dlg.DoModal();
Again, try to redesign the things. You should not have the UI thread blocked.
--
=====
Arman
|
|
|
|
|
iayd wrote: How can I create a new dialog box in a worker thread?
As Arman suggested you should re-evaluate your design.
What problem are you trying to solve by creating a secondary thread, i.e. why do you think you need it?
Could the dialog box be modeless and created from the main thread instead?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
It is not possible to create the dialog box from main thread for my project.I should add a worker thread and wait for a situation will be occur.I think there should be a way to do this in this way.(?)
|
|
|
|
|
Hi,
You create the dialox box from main thread and set this dialog as hidden. Now create a worker thread and wait for the situation. When the situation occures you just set the dialog visible.
Manoj
Never Gives up
|
|
|
|
|
iayd wrote: I think there should be a way to do this in this wa
Well, you cannot create windows in threads that don't process messages.
This means that if you create a worker thread, you cannot create a modeless dialog in that thread. You could however create a modal dialog because it will pump messages inside an internal message pump until the dialog is closed. But the call to DoModal() won't return until the dialog is dismissed. This means that your worker thread cannot do anything else but showing that dialog.
If you want to create a modeless dialog, or any window, from another thread than your main thread, it will have to be a UI-thread.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
how to add gif image in a button control in mfc. pls help me
|
|
|
|
|
|
You can read your file(gif) with CImage class and use of SetBitmap of CButton for set this file
|
|
|
|
|
see this code (set bitmap to true on the property of button)
#include AtlImage.h
CImage m_Image;
m_Image.Load("c:\\ad2.gif");
m_Button1.SetBitmap(m_Image.Detach());
|
|
|
|
|
i used cimage class. but it shows "Cannot open include file: 'atlimage.h':" is there any files to be included other than atlimage.h
|
|
|
|
|
Whats your compiler? you can also use of GDI+.
|
|
|
|
|
no sir i cant use gdi+ also because of same error. which compiler i have to use
|
|
|
|
|
|
See if this helps.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi to all.
I'm having problems when I put '#include "imapi.h"' line in my app (using IMAPIv1 for writing data on CD)
But the moment I do so and compile several errors appear, all warning some tag structure redefinition. E.g.
c:\program files\microsoft sdk\include\propidl.h(198) : error C2011: 'tagCABSTR' : 'struct' type redefinition
I've download Feb2003-SDK ant put it on top of the Tools->Option->Directories, but didn't help!
Anyone know what to do?
|
|
|
|
|
josip cagalj wrote: I'm having problems when I put '#include "imapi.h"' line in my app...
I added the file to one of my projects and it compiled fine. What does the file look like where you added it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You mean you added line not File?
I created dialog where user can add several files/folders in an listctrl and then record them on CD.
Now, I'm trying to write on CD using IMAPI v1.0 but the moment I include imapi.h
and try to compile errors begin line up. Example:
c:\program files\microsoft sdk\include\propidl.h(144) : error C2011: 'tagCAUB' : 'struct' type redefinition
Should I try to disable this .h file?
I followed 'CD burner' article (for vc7, i'm using vc6 all the same) where states:
<br />
1. Include imapi headers "imapi.h" and "Imapierror.h"<br />
<br />
#include "imapi.h"<br />
#include "Imapierror.h"<br />
<br />
2. Declare your IMAPI variables.<br />
<br />
IDiscMaster *pDiscMaster=NULL;<br />
IJolietDiscMaster *pJolietDiscMaster=NULL;<br />
IEnumDiscRecorders *pEnumDiscRecorders=NULL;<br />
IDiscRecorder *pDiscRecorder=NULL;<br />
IStorage* pStorage = NULL;
but not for me!
THX
the sdk is from Feb2003, should i dawload new (please send me a link if so)
|
|
|
|
|
josip cagalj wrote: You mean you added line not File?
These are one in the same. The #include preprocessor directive does add/insert the contents of the file at the point where the directive appears.
What does the file look like where you added it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
My English is not so good so i'm afraid i dont quit understand when you say
What does the file look like where you added it?
But here is the whole .h my file:
#include "KCSideBannerWnd.h"<br />
#include "MyBrowser.h"<br />
<br />
<br />
<br />
class CBurn : public CDialog<br />
{<br />
public:<br />
CBurn(CWnd* pParent = NULL);
CString IzaberiFolder(BOOL bNetwork);<br />
CString m_sIniFolder;<br />
enum { IDD = IDD_BURN };<br />
CButton m_btnAddFolder;<br />
CButton m_btnDel;<br />
CButton m_btnAdd;<br />
CMyBrowser m_lsFiles;<br />
CComboBox m_cmbRecorder;<br />
<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
CKCSideBannerWnd m_banner;<br />
void FillRecorders(); <br />
<br />
virtual BOOL OnInitDialog();<br />
virtual void OnOK();<br />
afx_msg void OnBtnAdd();<br />
afx_msg void OnBtnAddFolder();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
#endif // !defined(AFX_BURN_H__E8A4E285_5D2F_439A_B77E_3393660D2EAC__INCLUDED_)<br />
this is fresh, I still need to add a whole lot of functions and ....
Once again thanks for trying to help me
|
|
|
|
|
You need to get in the habit of including all header files that you did not create (e.g., imapi.h) in the stdafx.h file. No, it's not required, but you'll save yourself a lot of aggravation.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks, I'll try that.
I thought that putting stuff in the stdafx.h causing program build last longer, I have that habit with something which I need in a few places. But I'm recording on CD in one place so i thought I can include imapi.h there.
I did what you recommended, included files in the stdafx.h and same errors occur:
Compiling...<br />
StdAfx.cpp<br />
c:\msdev\sdk include\propidl.h(143) : error C2011: 'tagCAUB' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(149) : error C2011: 'tagCAI' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(155) : error C2011: 'tagCAUI' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(161) : error C2011: 'tagCAL' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(167) : error C2011: 'tagCAUL' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(173) : error C2011: 'tagCAFLT' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(179) : error C2011: 'tagCADBL' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(185) : error C2011: 'tagCACY' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(191) : error C2011: 'tagCADATE' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(197) : error C2011: 'tagCABSTR' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(203) : error C2011: 'tagCABSTRBLOB' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(209) : error C2011: 'tagCABOOL' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(215) : error C2011: 'tagCASCODE' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(221) : error C2011: 'tagCAPROPVARIANT' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(227) : error C2011: 'tagCAH' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(233) : error C2011: 'tagCAUH' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(239) : error C2011: 'tagCALPSTR' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(245) : error C2011: 'tagCALPWSTR' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(251) : error C2011: 'tagCAFILETIME' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(257) : error C2011: 'tagCACLIPDATA' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(263) : error C2011: 'tagCACLSID' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(284) : error C2011: 'tagPROPVARIANT' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(486) : error C2011: 'tagPROPSPEC' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(497) : error C2011: 'tagSTATPROPSTG' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(509) : error C2011: 'tagSTATPROPSETSTG' : 'struct' type redefinition<br />
c:\msdev\sdk include\propidl.h(1402) : error C2084: function 'void __cdecl PropVariantInit(struct tagPROPVARIANT *)' already has a body<br />
Error executing cl.exe. <br />
Don't know what to do anymore
|
|
|
|
|
I did it!!!
No compile errors no more!
I've put include files i stdfax.h then I played some with Tools->Option->Directories property (put WindowsPlatformSDK ver Feb2003 to top) and suddenly no more errors on compile!
One BIG thanks to everybody who helped me (especially David Crow ). But no time to rest guy's soon I'll be back with new stuff and bug you some more, but I think you wont mine me
THANKS
P.S.
I hope I'm not going to ask you any more about this topic
|
|
|
|