|
I'm attempting to set my XML document's encoding at the start of the file with SAX's IMXWriter interface.
I'm using
pWriter->put_encoding(CComBSTR("UTF-8"));
pWriter->put_standalone(VARIANT_TRUE);
where pWriter is a CComPtr with interface IMXWriter.
The put_standalone command works, but the put_encoding is ignored and stays at UTF-16. What's wrong? I'm getting an HRESULT of 0 from both commands, so apparently no problems there.
CodeGuy
The WTL newsgroup: 910 members and growing ... http://groups.yahoo.com/group/wtl
|
|
|
|
|
how to convert parameter 2 from 'struct HWND__ *' to 'struct HWND__ ** '?
|
|
|
|
|
¶m2
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I have noticed that many people use (rand() % X) to get an integer between 0 and X. I suspected that this actually would return some numbers more often than others. I ran some checks and I found out it worked as I suspected. For example...
const largeNumber = 10000000;
int count[30000];
for (int i = 0; i < RAND_MAX; i++)
{
count[i] = 0;
}
int number = 0;
for (i = 0; i < largeNumber; i++)
{
number = rand() % 30000;
count[number]++;
}
float avgLow = float(count[0]);
for (i = 1; i < RAND_MAX - 30000; i++)
{
avgLow = (avgLow + count[i]) / 2;
}
float avgHigh = float(count[++i]);
for (i++; i < 30000; i++)
{
avgHigh = (avgHigh + count[i]) / 2;
}
cout << "Avg: 0 - 2767: " << avgLow << endl;
cout << "Avg: 2768 - 30000: " << avgHigh << endl;
As you can see, all the numbers under (RAND_MAX - 30000) has been returned twice as often by (rand() % 30000). I wonder if there is a better (and fast) way go get a random integer between 0 and X?
|
|
|
|
|
Mersenne Twister
http://www.math.keio.ac.jp/~matumoto/emt.html
CodeGuy
The WTL newsgroup: 910 members and growing ... http://groups.yahoo.com/group/wtl
|
|
|
|
|
I am cross posting this because the need is urgent.
The code below, takes a parameterized object name, looks for a specific interface
and trys to call its methods.
It finds the interface with no difficulty but gets the error 0x8007806ba
(The RPC server is unavailable. ).
The same calls work from a VB test script. I'm running this on a Windows 2k server
with SP 2. I've checked all the security parameters (DCOMCNFG) all are set to
default, the same as for the other objects that work fine...
This code used to work, I've modified the object, transfered it to a new program
and now it fails. I did change the name of the interface (I seperated the methods
out from another interface). So I tried the old object, everything works fine. (difference shown as commente line (//OLD.)
It would appear there is something wrong with my new object. I would think the
problem must be in the new object, except that I wrote a VB test app, and it works fine. This makes me think the problem is NOT in the object.
Please Help!!
I'd include the code for the object, but its large, and I'm not sure which parts would be useful...
Thanks, Bill
*******************************************************************************************
This VB code works fine
Dim apminfo As New APMOBJECTLib.MessageInfo
Private Sub Command1_Click()
Dim t As String
t = apminfo.GetFunction("sfddsfsdlfksdflk")
End Sub
*****************************************************************************************
This code locates and connects to the interface (MessageInfo). Every thing here succeeds...
CErrorInfo CServiceMessage::UnpackMessage(VARIANT vBody)
{
CErrorInfo err;
CoInitialize(NULL);
VARIANT vResult;
_bstr_t bstrValue;
m_strBody = GetMessageAsString(vBody);
try
{
// Get Function handler object
CLSID ID;
m_pBroker=NULL;
//OLD CString strObjName = "APMObj.CFunction"; // This works fine when activated
CString strObjName = "APMObject.MessageInfo"; // New object.
// The following line of code succeeds
HRESULT hr = CLSIDFromProgID( strObjName.AllocSysString(), &ID);
if (hr != S_OK)
{
LPTSTR lpMsgBuf;
CString strError;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL ) == 0 ) // Couldn't find error code
{
lpMsgBuf = "Unknown Error";
}
strError.Format("%s: %s %s Error %d: %s.","CConfigServices::Load()",
"Attempting to find object ", m_pParent->m_strObjectName,
hr, lpMsgBuf);
err.SetError(ERR_SEVERITY_MAJOR, CONFIGERROR + CString(strError));
LocalFree(lpMsgBuf);
return err;
}
hr = CoCreateInstance(ID, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, (void **)&(m_pBroker));
if (hr != S_OK)
{
// error handling
}
vResult = GetValue(vBody,CString("GetPriority"),VT_I4);
*******************************************************************************
This code fails
VARIANT CServiceMessage::GetValue(VARIANT vBody, CString strField, int iType)
{
DISPID dispID;
HRESULT hr;
CErrorInfo err;
LPOLESTR olestr;
VARIANT vResult;
try
{
// Unpack function name
olestr = strField.AllocSysString();
TRACEX("Get ID of " + strField);
// the following line of code fails if the new object and interface is used. It works if
// the old object name and interface is used.
hr = m_pBroker->GetIDsOfNames(IID_NULL, &olestr, 1, LOCALE_USER_DEFAULT,
&dispID);
if (hr != S_OK)
// hr is = 0x800706ba (RPC Server Not Found)
Thanks for the help,
Bill
|
|
|
|
|
Is there any way to create Controls or declare variables in MFC?
for exapmle:
int i;
i = rand() % 10;
Static[i].ShowWindow(SW_HIDE);
please help! or is there any other way to do what I want?
|
|
|
|
|
Yes you can create a array of Control, and create the control using the Create Function.
Cheers
Carlos Antollini.
|
|
|
|
|
Can you give me a little example how to do that?
|
|
|
|
|
The Sample
CButton* pbtn = new CButton[2];
RECT rc = {0, 0, 100, 40};
pbtn[0].Create("Button 1", WS_VISIBLE | WS_CHILD, rc, this, 100);
rc.top += rc.bottom;
rc.bottom += rc.bottom;
pbtn[1].Create("Button 2", WS_VISIBLE | WS_CHILD, rc, this, 101);
Cheers!!!
Carlos Antollini.
|
|
|
|
|
CStatic * pStatic = new CStatic[10];
You could also create pointers and push them into a vector.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I am working with V C++ Help Workshop. I've created the .rtf file (several times) and recompiled (several times), deleted the .hlp file and recompiled (several times), and I still see pages/topics that are NOT in the .rtf file. Almost as though Help Workshop is not recompiling.
All help appreciated
Richard
|
|
|
|
|
Hi,
The Operating System is Window 2000 and I have support for Arabic and English. Now I want to write an application in VC++ whose interface is in arabic.
eg I want that in "Edit Box" the value should displayed
in Arabic format.
and the Caption of buttons is in arabic too.
I am new commer in this "multi-language" development so if some-one knows any thing in this regards. Kindly response me.
Have a nice wishes for my helper.
|
|
|
|
|
I have a lot of experience in Cyrillics Idioms.
I worked in Hebrew and Arabic, and in English, Spanish, Portugesse, Russian, France, etc.
What do you Need?
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Which variable is for the Parent-Window in MFC? (CWnd)
Here is the problem: Parameter 5
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, Parent, IDC_X, NULL);
or how can I create a Control manually in MFC?
|
|
|
|
|
try
m_hWnd
or
GetParent()
|
|
|
|
|
m_hWnd does not work...
and GetParent causes an Error
|
|
|
|
|
If you want to create a child control, the parent window must exist.
If you want to create a control in a CDialog, you must do it in the OnInitDialog(), after calling de default OnInitDialog()
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, m_hWnd, IDC_X, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
of in the OnInitialUpdate() if you want to create a control in a CView
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, m_hWnd, IDC_X, NULL);
}
|
|
|
|
|
I'm sure this problem must have been solved many moons ago, and my newbieness is just holding me back. I am trying to draw a couple of buttons on a dialog using Win32, that contain up and down arrows. I can use WM_SETFONT, to set the Symbol font, but how do I set the character to appear on the button? If I could use a bitmap button that would be OK, but I cannot use MFC. Any ideas anyone?
Any help would be gratefully appreciated.
ChrisP
|
|
|
|
|
Is WM_SETTEXT message what you're looking for? Maybe I haven't understood your problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
My Class is using some bitmap, there not very big I'd like that only one instance of the bitmap exist for all instance of my class.
In java it's static member of the class, in MFC I've try to do
Class MyClass: public CWnd
{
...blablabla...
private:
static CBitmap MyBitmap;
...blablabla
}
and the linker said
MyClass.obj :error LNK2001:unresolved external symbol "private: static class CBitmap MyClass::MyBitmap" (?MyBitmap@MyClass@@0VCBitmap@@A)
so what is wrong?
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
in a .cpp file, you need to have:
#include "MyClass.h"
CBitmap myClass::MyBitmap;
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
thanks, it was easy;)
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
What is the difference between
[code]
char something[64];
[/code]
and
[code]
char something = new char[64];
...
delete something
[/code]
I only know that the memory is allocated different, but don't know exactly how.
Is there one initialization which is better or faster?
thanks for your help
|
|
|
|
|
in a function
MyFunction()
{
char something[64];
[code]
}
the memory is static with the function itself, it's mean that window allocate some memory for the function and that include this 64 char
it's why we don't have to bother to delete this memory, it' will be flushed whit the function itself.
function2()
{
[code]
char something = new char[64];
...
delete something
[/code]
}
this way you call a function who call window, windows allocate memory and return a pointer to this memory. in each case the memory is allocated by windows but in one case it is allocate whit (and for) the function and in the other case it is allocated dynamicaly. In fact the when you start you'r program the something[64] is allocated. And when you close you'r program it is desallocated so it is faster because it is allocated one time, and in the other case it is allocated each time you call this function.
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
Le rêve est la seule chose vraiement réelle et vraiement consistante
|
|
|
|
|