|
I had to go the route of loading the library and reading the resource file,
After loading it I got the HRSC from the FindResource with the type RT_HTML [this is why I never was able to find anything on google].
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
|
Maybe, after all it was difficult to find on google so maybe, if i can find time.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Hi
Let's say I have a pointer to a BITMAPINFO structure, and the structure holds information about an RGB bitmap in memory. Is there a way for me to directly write some string on top of the bitmap?
Currently I do it like this:
HDC hDC = CreateCompatibleDC(NULL);
void *pDIB;
HBITMAP hBmp = CreateDIBSection(hDC, pBmpInfo, DIB_RGB_COLORS, &pDIB, NULL, NULL); //pBmpInfo in of type BITMAPINFO*
memcpy(pDIB, pData, iWidth * iHeight * 3); //iWidth and iHeight are the width and height of the image, respectively, and pData is a pointer to the bitmap's pixel values, multiplied by 3 because it's RGB
SelectObject(hDC, hBmp);
DrawText(hDC, "This is a test", strlen(cstrStatus), &CRect(5, 5, iWidth, iHeight), DT_LEFT);
memcpy(pData, pDIB, iWidth*iHeight*3);
DeleteObject(hBmp);
DeleteDC(hDC);
So basically I first copy the bitmap's pixel values to a buffer created using CreateDIBSection, write the text on the DIB, and copy the DIB pixel values back to the original bitmap pixels' location. Is there a more efficient way to do this without copying the pixel values back and forth between the two buffers (something like writing the text directly to pData)? Due to the way the system is designed, my function must work on preloaded BITMAPINFO* input that resides in memory, not bitmap image files or other types of input. And because my system needs all the speed it can get, any tips on how to make the above code faster will be greatly appreciated.
Thanks!
|
|
|
|
|
Indrawati wrote:
Is there a more efficient way to do this without copying the pixel values back and forth between the two buffers (something like writing the text directly to pData)?
nope. not if you're using the GDI text functions - they require DCs, and DCs require HBITMAPs and HBITMAPs require you to SelectObject them, etc.. if you want to get into 3rd party text-rendering engines, you might be able to avoid it, but that's probably a lot more trouble than it's worth.
Software | Cleek
|
|
|
|
|
How can I Highlight a CTreeCtrl Item, without set focus on CTreeCtrl?
|
|
|
|
|
Sounds like you need to make sure the tree control has the TVS_SHOWSELALWAYS style.
|
|
|
|
|
right! thank you. but when no focus, the color turns to grey, instead of blue.
|
|
|
|
|
Sure, but that's the way the control works. Highlight a file in Explorer, and give focus to another window - you get the same effect.
|
|
|
|
|
|
Hello,
I have trouble with the following few lines:
int CGoalsListView::GetItemFromPoint(CPoint point)<br />
{<br />
<br />
int nItem = 0;<br />
<br />
CRect rcItem, rcItemClient;<br />
nItem = 0;<br />
....
In the debugger, I see that as soon as the instruction for nItem = 0; executes, all locals change as though the stack just got slammed by something: nItem now equals some very large number, and the point is rewritten.
Any ideas about why this is occuring and how to fix it?
thanks,
JennyP
|
|
|
|
|
|
error C2440: '=' : cannot convert from 'std::string' to 'System::String __gc *'
How can solve this problem?
Please help me
|
|
|
|
|
ozgul wrote:
How can solve this problem?
By showing us the code in context.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
My code is;
#include "stdafx.h"
#include "SysInfo.h"
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
using namespace System::Data;
using namespace System::Net;
using namespace System::IO;
using namespace System::Text;
using namespace std;
int _tmain()
{
SysInfo sysInfo = new SysInfo();
String* uriString;
String* postData;
uriString = "http://localhost/WebApplication3/WebForm1.aspx";
WebClient* myWebClient = new WebClient();
myWebClient->Headers->Add(S"Content-Type", S"application/x-www-form-urlencoded");
//postData = Convert::ToString(sysInfo.getCpuModel());
postData = sysInfo.getComputerName();
Byte byteArray[] = Encoding::ASCII->GetBytes(postData);
Byte responseArray[] = myWebClient->UploadData(uriString, S"POST", byteArray);
Console::WriteLine(S"\nResponse received was {0}",
Encoding::ASCII->GetString(responseArray));
}
|
|
|
|
|
i don't for your answer, but i'd like to give some advices.
ozgul wrote:
using namespace System;
using namespace System::Data;
using namespace System::Net;
using namespace System::IO;
using namespace System::Text;
if you are using System:: ,
you don't have to using parts of it... you can so delete the 4 lines following.
ozgul wrote:
uriString = "http://localhost/WebApplication3/WebForm1.aspx";
in general, we are talking about URL s, not URI s.
at last, where does your code crash (about what line) ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I assume you have a problem with the following line!
postData = sysInfo.getComputerName();
Is this correct!? Everything else looks fine IMO.
You should change it to read
postData = sysInfo.getComputerName().c_str();
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I'm not familiar with the managed extension ...
did you try copying the C buffer of the std::string ?
something like :
std::string s;
yourSystemStringVariable = s.c_str();
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
visibly, you are trying to assign a string* with a string.
didn't you forget the address operator (& ) ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
A lot of thanks....
I changed this line
postData = sysInfo.getComputerName();
with
postData = sysInfo.getComputerName().c_str();
Then it worked very well.
Again thanks every body...
|
|
|
|
|
hello everyone,
I am trying to read in a list structure which is serialized as
m_DataPointerList.Serialize( ar );
where m_DataPointerList is defined as :
CTypedPtrList m_DataPointerList;
and class CDataPointer is declared as:
class CDataPointer : public CObject
{
public:
CDataPointer();
protected:
DECLARE_SERIAL(CDataPointer)
protected:
public:
unsigned long Time; unsigned char Channel;
unsigned char Rate;
public:
virtual void Serialize(CArchive& ar);
};
and defined as:
IMPLEMENT_SERIAL(CDataPointer, CObject, 1)
CDataPointer::CDataPointer()
{
}
void CDataPointer::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << Time;
ar << Channel;
ar << Rate;
}
else
{
ar >> Time;
ar >> Channel;
ar >> Rate;
}
}
I am having some difficulties( i donno why?) in reading it in using the same serializing command ie:
m_DataPointerList.Serialize( ar );
is there any thing i am overlooking while i am doing this??
on the other hand,
I try to read this using a 'for' loop
which iterates for the number of occurances of CDataPointer. but i have to add an offset at the end of every iteration if I were to read the next iteration correctly.
something like
nDataCounter=ar.ReadCount();
for(i=0;i
{
ar>>Time[i];
ar>>Channel[i];
ar>>Rate[i];
ar.Flush();
pFile->Seek(offSET, CFile::current);
}
i dont understand why i have to provide this offset.and i have trouble choosing the correct offSET as it varies for different lists. again is there something i am doing wrong ?
Can please you give me some insight into these two issues??
Thanks a lot
|
|
|
|
|
sorry m_DataPointerList has to be defined as
CTypedPtrList<coblist,cdatapointer*> m_DataPointerList;
and not as typed wrongly
|
|
|
|
|
|
i am not serializing each variable but the list as a whole like
m_DataPointerList.Serialize();
i donno why i am not able to make the deserialization code work if i do
m_DataPointerList.Serialize() during deserialization.
I debugged at what's going wrong at the instant when I call: m_DataPointerList.Serialize() . The error I get is
Warning: Cannot load CDataPointer from archive. Class not defined.
CArchive exception: badClass.
When i further debug as to why this is happening I think this is where it is getting wrong. It goes into this class(code shown below) with lpszClassName = CDataPointer and tries to compare with pClass->m_lpszClassName, in the for loop where it searches classes in shared DLL's. I get some classes in pClass->m_lpszClassName but not CDataPointer. eventually since it couldnt find a matching class this function returns NULL.
CRuntimeClass* PASCAL CRuntimeClass::FromName(LPCSTR lpszClassName)
{
CRuntimeClass* pClass;
// search app specific classes
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
AfxLockGlobals(CRIT_RUNTIMECLASSLIST);
// this for loop is skipped
for (pClass = pModuleState->m_classList; pClass != NULL;
pClass = pClass->m_pNextClass)
{
if (lstrcmpA(lpszClassName, pClass->m_lpszClassName) == 0)
{
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
return pClass;
}
}
AfxUnlockGlobals(CRIT_RUNTIMECLASSLIST);
#ifdef _AFXDLL
// search classes in shared DLLs
AfxLockGlobals(CRIT_DYNLINKLIST);
//enters this for loop
for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL;
pDLL = pDLL->m_pNextDLL)
{
for (pClass = pDLL->m_classList; pClass != NULL;
pClass = pClass->m_pNextClass)
{
//comparison is done here
if (lstrcmpA(lpszClassName, pClass->m_lpszClassName) == 0)
{
AfxUnlockGlobals(CRIT_DYNLINKLIST);
return pClass;
}
}
}
AfxUnlockGlobals(CRIT_DYNLINKLIST);
#endif
return NULL; // not found
}
I really dont know how i can tackle pClass->m_lpszClassName so that it picks up the name of m_lpszClassName (here CDataPointer)
Also i can read in the values using the for loop but i need to provide some offset at the end of each iteration which is quite tricky for me.Please give me some suggestions on this
|
|
|
|
|
1) From Programming MFC book by Jeff Prosise...
WriteObject ultimately calls the object's Serialize function to serialize the object's data members, but before it does, it writes additional information to the archive that identifies the class from which the object was created.
For example, suppose the object being serialized is an instance of CLine. The very first time it serializes a CLine to the archive, WriteObject inserts a new class tag—a 16-bit integer whose value is -1, or 0xFFFF—into the archive, followed by the object's 16-bit schema number, a 16-bit value denoting the number of characters in the class name, and finally the class name itself. WriteObject then calls the CLine's Serialize function to serialize the CLine's data members.
If a second CLine is written to the archive, WriteObject behaves differently. When it writes a new class tag to the archive, WriteObject adds the class name to an in-memory database (actually, an instance of CMapPtrToPtr) and assigns the class a unique identifier that is in reality an index into the database. If no other classes have been written to the archive, the first CLine written to disk is assigned an index of 1. When asked to write a second CLine to the archive, WriteObject checks the database, sees that CLine is already recorded, and instead of writing redundant information to the archive, writes a 16-bit value that consists of the class index ORed with an old class tag (0x8000). It then calls the CLine's Serialize function as before. Thus, the first instance of a class written to an archive is marked with a new class tag, a schema number, and a class name; subsequent instances are tagged with 16-bit values whose lower 15 bits identify a previously recorded schema number and class name.
So, assuming you have 2 objects in your list, both of which have zero for all their member variable values, the file should look like this...
<br />
Bytes Description<br />
(Hex)<br />
----- -----------<br />
02 00 Number of objects in list (WORD)<br />
<br />
FF FF New class tag (WORD)<br />
01 00 Schema number (WORD)<br />
0C 00 Length of "CDataPointer" (WORD)<br />
43 44 61 74 61 50 6F 69 6E 74 65 72 "CDataPointer" (char)<br />
00 00 00 00 Time value for 1st object (DWORD)<br />
00 Channel value for 1st object (BYTE)<br />
00 Rate value for 1st object (BYTE)<br />
<br />
01 80 Class tag for 2nd object (WORD)<br />
00 00 00 00 Time value for 2nd object (DWORD)<br />
00 Channel value for 2nd object (BYTE)<br />
00 Rate value for 2nd object (BYTE)<br />
<br />
Note: See CArchive::ReadCount code in your Visual Studio folder for explanation as to why the count is a WORD value in this case. <br />
So now you know what those offsets are.
2) The only thing I can think of concerning a bad class name error, is that you've renamed the class (or changed something else in the class) since the last time it was written to the file. For example, if your class was originally called CDataPointer, the serialization process will have written "CDataPointer" to file when it's saved. When the file is read back in, the serialization process finds "CDataPointer" in the file, and thus tries to create an object of type CDataPointer, which it can't do since it's been renamed to CChangedClassName.
You should download a Hex editor, then you can open the file up, and see if the data is as expected.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|