|
Here[^] are some possible suggestions.
|
|
|
|
|
|
locale loc("chs");
mbstate_t mystate;
char origin[] = "追求追求";
wchar_t dest[9] = { 0 };
const char * pc;
wchar_t * pwc;
const codecvt<wchar_t,char,mbstate_t>& myfacet =
use_facet<codecvt<wchar_t,char,mbstate_t> >(loc);
codecvt<>.in() translates char into wchar_t characters, but the first letter of origin[] is always translated wrong,the remaining characters are fine.
could someone help me out?
|
|
|
|
|
Cold_Fearing_Bird wrote: char origin[] = "追求追求";
You are trying to set a unicode/wide string to ANSI buffer.
|
|
|
|
|
|
I have tried the line of code that you complain about, but it compiles successfully. Please try and be more clear about your problem.
|
|
|
|
|
Yes,Thank you.i debug in detail this time. I know where is wrong . i know what caused this problerm.
thank you again.
|
|
|
|
|
Please don't delete your messages; if you find the answer yourself then post the information so others may benefit from it.
|
|
|
|
|
I want to write a REG_MULTI_SZ value (e.g 100-104) in registry. My code is like
<pre lang="c++">HKEY objHKey;
CString strReturn;
CString subkey("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters");
// Open Registry key for Vlc Path
if( RegOpenKey( HKEY_LOCAL_MACHINE,
(LPCTSTR)subkey, // what to open
&objHKey // on success, handle goes here
) == ERROR_SUCCESS )
{
unsigned char * format = new unsigned char [100];
unsigned char p1[5] = "998";
unsigned char p2[5] = "999";
sprintf((char*)format, "%s\\0%s\\0\\0", p1, p2);
int ILenght = 20;//strlen(format);
unsigned char *ptr= (unsigned char *) strTemp.GetBuffer(0);
if(ERROR_SUCCESS != RegSetValueEx(objHKey,
_T("ReservedPorts"),
NULL,
REG_MULTI_SZ,
//(BYTE*)_T("1000-1004"),
ptr,
strTemp.GetLength()))
{
AfxMessageBox(_T("Failed to update in registry."));
}
// Close the registry
RegCloseKey( objHKey );
}</pre>
But this is not updating in registry.
|
|
|
|
|
sprintf((char*)format, "%s\\0%s\\0\\0", p1, p2);
The result of the above command will produce the string:
998\0999\0\0
which is obviously not what you want; the format string should be "%s\0%s\0\0" .
You also say that this is not updating in registry; do you get the error message or see some other problem? Are you running this code with administrator privileges and have you opened your registry key with the correct permissions for updating values?
|
|
|
|
|
great 5p+
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Hi All,
While running my Activex in IE i'm getting a warning popup, saying that this Activex Is not safe.
Can any body tell me how to disable this warning?
Thank You All.
|
|
|
|
|
|
Thank You. I've fixed this issue.
But If i register my Activex using command "Regsvr32 /s MyActiveXCtrl.ocx", then its working. Is there any other way to register this ActiveX? Currently I'm calling this ActiveX methode in java scrpit.
|
|
|
|
|
Hi,
Not sure if the way we register the ActiveX has anything to do with the 'No Safe' message displayed by the web browser.
Thanks,
Rejeesh
|
|
|
|
|
You are right, register the ActiveX has anything to do with the 'No Safe' message displayed. but if we want to use the Activex we have to register it. Now I'm doing same manually by using Regsvr32 /u D:\MyActivexCtrl.ocx. How can i do so programeticall? And also If I'm trying to register in some system it is giving error LoadLibrary(".ocx") failed - This application has failed to start because
the application configuration is incorrect.
How to fix this?
|
|
|
|
|
I assume you need to implement IPropertyBag2 interface to get rid of activeX warning. I did it long time ago. don;t remember the details as of now.
HTH.
|
|
|
|
|
I'm getting some very strange behavior in an MDI MFC application with tabbed views I'm working on that I can reproduce easily in any new MDI application I make (that uses tabbed views), and I can't seem to fix it. I'm using Visual Studio 2010. I made a sample application to demonstrate my problem. In my CView (in my example called CNewTestView) I override CView::OnActivateView. I can't seem to call DestroyWindow in OnActivateView, but ONLY when the view is activated by switching to it through the Windows 7 Aero Preview thumbnails. ie. When I switch to a non-active view by either clicking a tab or by pressing CTRL+Tab there are no problems at all, but when I hover the mouse over the application icon in the taskbar and then switch views by clicking on the non-active one then the problem shows up. In the application, I create 2 tabs by pressing Ctrl+N.
As an example, I made a member variable of type CEdit called CNewTestView::m_edit, in a new MFC project with tabbed MDI views, and no other code at all added or modified. Here's the code for OnActivateView:
void CNewTestView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
if (bActivate)
{
if (m_edit.GetSafeHwnd())
m_edit.DestroyWindow();
m_edit.Create(WS_VISIBLE | WS_BORDER | WS_CHILD, CRect(0,0,100,20), this, 1234);
}
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}
I get an assertion in CWnd::DestroyWindow on line 1047 when the HWND of the CEdit is being looked up in the HWND map returned by the call to afxMapHWND. Here's the code in wincore.cpp where the assertion occurs:
if (pWnd != NULL)
{
#ifdef _DEBUG
ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
#endif
}
Note that for the assertion all I get is a buzz noise to indicate the assertion, but the debugger doesn't actually break at the assertion. If I compile a Release version I still have a problem (basically I can't recreate the window, and so the application doesn't work properly). If instead I slightly delay the call to DestroyWindow, eg. if I destroy the window in CView::OnTimer after setting a timer in OnActivateView or in a message handler after calling PostMessage then there's no problem at all. Unfortunately I can't do this, since in my real application I'm developing there seems to be other calls resulting from OnActivateView that, after a long line of calls, eventually results in a call to CWnd::DestroyWindow, and the application has gotten large enough that it would be very time consuming to implement the PostMessage call to work with no assertions at all. Does anyone know what's going on?
In the example I gave above I did not add anything else at all to the empty application other than what I mentioned in this email.
Martin
|
|
|
|
|
I fixed the PostMessage problem I mentioned. Turned out the problem was with my code, so everything's working well with my call to PostMessage in OnActivateView. Regardless, I'm still curious as to why I can't call DestroyWindow of a child within OnActivateView of the CView. (I forgot to mention that I'm using a document/view architecture)
|
|
|
|
|
I don't have access to MFC, unfortunately, but can you attempt to debug the application and follow the code into m_edit.DestroyWindow()? It might give you some clue as to when things start to go wrong inside DestroyWindow.
I've read something about LookupPermanent going wrong when it is called from the wrong thread. I can't imagine that to be the problem, but it's something you might want to rule out, just to be sure.
|
|
|
|
|
I know Active document server can render a ole file such as office document, but i found AcroPDF also use Active document server technology to load .pdf files in IE.
When I open a pdf file with UltraEdit,see binary data,not seems like a ole file.
why?
and anyone can tell me how can i create a Active document server to render a txt file.
thanks.
|
|
|
|
|
This is the ATL/WTL/STL forum, your question does not seem to have anything to do with any of those subjects. Please try a more appropriate section.
|
|
|
|
|
ATL is a way to create ActiveX docuemnt,i think my subject accordant for ATL forum
|
|
|
|
|
How to Check the iterator is valid?
|
|
|
|