|
Add more RAM?
Use a smaller bitmap?
Those are actually serious answers. I'm not expert on GDI+, but I know it can do all sorts of clever things for you, which may require it to make multiple copies of a bitmap to work on, so it may be greedier than you think.
Now you'll tell me the bitmap is only 64x64 pixels, and I'm talking rubbish!
Iain.
|
|
|
|
|
The bitmap is created according to the size of the client area.
I create a Graphics object using the bitmap, in OnCreate
<br />
CRect rc;<br />
GetClientRect(&rc);<br />
Graphics g(GetSafeHwnd());<br />
m_pMemBmp=::new Bitmap(rc.Width(),rc.Height(),&g);<br />
m_pMemGraphics=::new Graphics(m_pMemBmp);<br />
m_pMemGraphics->Clear(Color::White);<br />
|
|
|
|
|
Hi all!
I am working on a application which is performance intensive. The bulk of the application is spread across several shared DLL modules for reusability. I have used C++ for the benefits of OOP, and the system is functioning well.
I am designing a scripting system to facilitate future expansion with cross-platform support. I have a basic scripting engine working. Scripts are able to link to and call C-style functions from dll modules. I am finding the need to use class within the scripting system, and have found several ways for which I can have a script link to a DLL module and use classes.
The key two constraints here are:
- performance, there are many small methods which will be called upon extremely frequently and so it is very important to minimize overhead here at all other costs.
- Cross-platform compatability at build time only, scripts will be cross-platform compatible already.
Idea #1 - Allocate and release objects from within the DLL using exported C functions. Add additional exported C functions for each class method, and convert all class methods into simple inline wrappers.
Problem: This may cause double function calls when interacting with class objects
Idea #2 - Somehow devise an approach which can link to exported C++ functions where the 'this' value could somehow be provided.
Problem: It is very important that this is compatible with other compilers, unfortunately (as far as I can tell) there is no standard for this.
Link functionality could be specialised for each platform (i.e. Windows, UNIX) simply by using seperate implementation files. Sadly, the same cannot be said for different compilers as there are many different compilers, and there is no way that I could support all of them.
It would be great to hear your ideas and experiences with similar situations. Is there a better way which I haven't yet found?
Many thanks!
Lea Hayes
|
|
|
|
|
Hi, I have developed an application that uses the winscard API to work with Smart Cards. The problem is that when Windows XP locks the session where the application is open and running, and the application calls the function SCardGetStatusChange, the call does not return any more and in the System Log of the Event Viewer appears the following error:
Smart Card Reader 'OMNIKEY CardMan 3x21 1' rejected IOCTL GET_STATE: Access is denied.
Source: SCardSvr
Event_ID: 610
I would really appreciate any hint about this problem. If I you know of a better place to post this question could you please tell me and I'll remove the question from this forum if it is an off-topic.
Thanks,
Federico
|
|
|
|
|
I have been doing smartcard application programming with WinSCard library for my company, which is a smartcard reader vendor, for 5 years. I cannot be sure if there isn't anything wrong in your code. But from my experience, most often this situation was caused by the fault of the device driver.
What would be the result when you:
1. Manually eject the card? (The call to SCardGetStatusChange should return immediately! )
2. Set a minimal timeout for the 2nd argument of SCardGetStatusChange.
Maxwell Chen
|
|
|
|
|
Thanks Maxwell!
The problem is that I can't reproduce this problem. This is happening in a client, and I have just the logs that I have introduced. The SCardGetStatusChange is called by a background thread in my application. The client tells me that after unlocking the Windows session the application does not detect anymore card insertions/removals. Reading the logs, I have found that the thread enters SCardGetStatusChange and it never comes out; and, of course, in the System log of the Event Viewer appears the message that I have reproduced above.
I will try with a minimal timeout and see what happens, exactly when the thread does not return anymore.
Thanks,
Federico
|
|
|
|
|
If you have the contact of the reader vendor, you can request a checked-build driver (which outputs debug messages). When the Windows session is unlocked, you would probably see the driver sunk into certain infinite loop around read FIFO or something. It usually has been the main reason SCardGetStatusChange not returns.
Of course there might be other reasons such as a third-party smartcard security application running when workstation session is locked and it uses poor method to poll card present status thus it exclusively locks the reader resource ...
Basically you can figure out most situations by reading the driver logs.
Maxwell Chen
|
|
|
|
|
Hi,
while compiling an old VC6 project to VC2005 (and also upgrading to the latest Ultimate Grid Version), I got the following messages:
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetDefaultInfo(void)" (?SetDefaultInfo@CUGCell@@QAEHXZ) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::AddCellInfo(class CUGCell *,class CUGCell *)" (?AddCellInfo@CUGCell@@QAEHPAV1@0@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetText(char const *)" (?SetText@CUGCell@@QAEHPBD@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::AppendText(char const *)" (?AppendText@CUGCell@@QAEHPBD@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::GetTextLength(void)" (?GetTextLength@CUGCell@@QAEHXZ) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetMask(char const *)" (?SetMask@CUGCell@@QAEHPBD@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::GetMask(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > *)" (?GetMask@CUGCell@@QAEHPAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: char const * __thiscall CUGCell::GetMask(void)" (?GetMask@CUGCell@@QAEPBDXZ) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetLabelText(char const *)" (?SetLabelText@CUGCell@@QAEHPBD@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::GetLabelText(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > *)" (?GetLabelText@CUGCell@@QAEHPAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: char const * __thiscall CUGCell::GetLabelText(void)" (?GetLabelText@CUGCell@@QAEPBDXZ) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetBool(int)" (?SetBool@CUGCell@@QAEHH@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetNumber(double)" (?SetNumber@CUGCell@@QAEHN@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::SetNumberDecimals(int)" (?SetNumberDecimals@CUGCell@@QAEHH@Z) is already defined in UGCell.obj.
1>ugrndm.lib(UGCell.obj) : error LNK2005: "public: int __thiscall CUGCell::GetNumberDecimals(void)" (?GetNumberDecimals@CUGCell@@QAEHXZ) is already defined in UGCell.obj.
(.. and another 661 lines!)
I added '#include "uglibsel.h" ' to my stdafx.h , and also created the ugdndm.lib (and udrndm.lib for release versions).
It looks like that I have defined them twice, but where?
Any help is appreciated.
quastman
|
|
|
|
|
The libraries are conflicting. Why do you need to link with both libraries?
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.
[my articles]
|
|
|
|
|
I don't link both, I just put both in the same directory as putting the debug version into the debug subdir and the release version un the release subdir (and adding these dirs to the "Additional Incluse for Debug / Release tab) does not work. If I only add one of the dlls, everything works fine, but as far as i understand, I need both (or am I wrong with this?)
quastman
|
|
|
|
|
Actually (maybe I'm wrong) seems that your application links with one of such libraries and, at the same time with an object file of the library itself.
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.
[my articles]
|
|
|
|
|
I think I found the problem: I added the libs to the project (as we are more than one programmer). In this case, both libraries are linked into the project. After removing them from the Project and just putting them in a directory, It works fine!.
Thanks for your help!
quastman
|
|
|
|
|
delete [] m_buffer;
////////////////////////// prepare to Cut
CFileException e;
CFile f;
if(f.Open(m_Path, CFile::modeRead,&e))
{
char szTmp[10];
WAVEFORMATEX pcmWaveFormat;
ZeroMemory(szTmp, 10 * sizeof(char));
f.Read(szTmp, 4 * sizeof(char)) ;
if (strncmp(szTmp, _T("RIFF"), 4) != 0) ;
//::AfxThrowFileException(CFileException::invalidFile, -1, f.GetFileName());
DWORD dwFileSize;/* = m_buffer.GetNumSamples() * m_pcmWaveFormat.nBlockAlign + 36*/
f.Read(&dwFileSize, sizeof(dwFileSize)) ;
ZeroMemory(szTmp, 10 * sizeof(char));
f.Read(szTmp, 8 * sizeof(char)) ;
if (strncmp(szTmp, _T("WAVEfmt "), 8) != 0) ;
//::AfxThrowFileException(CFileException::invalidFile, -1, f.GetFileName());
DWORD dwFmtSize; /*= 16L*/
f.Read(&dwFmtSize, sizeof(dwFmtSize)) ;
f.Read(&pcmWaveFormat.wFormatTag, sizeof(pcmWaveFormat.wFormatTag)) ;
f.Read(&pcmWaveFormat.nChannels, sizeof(pcmWaveFormat.nChannels)) ;
f.Read(&pcmWaveFormat.nSamplesPerSec, sizeof(pcmWaveFormat.nSamplesPerSec)) ;
f.Read(&pcmWaveFormat.nAvgBytesPerSec, sizeof(pcmWaveFormat.nAvgBytesPerSec)) ;
f.Read(&pcmWaveFormat.nBlockAlign, sizeof(pcmWaveFormat.nBlockAlign)) ;
f.Read(&pcmWaveFormat.wBitsPerSample, sizeof(pcmWaveFormat.wBitsPerSample)) ;
ZeroMemory(szTmp, 10 * sizeof(char));
f.Read(szTmp, 4 * sizeof(char)) ;
if (strncmp(szTmp, _T("data"), 4) != 0) ;
//::AfxThrowFileException(CFileException::invalidFile, -1, f.GetFileName());
m_pcmWaveFormat = pcmWaveFormat;
DWORD dwNum;
f.Read(&dwNum, sizeof(dwNum)) ;
//m_buffer=NULL;
m_buffer=new char[dwNum];
f.Read(m_buffer, dwNum) ;
m_dwNum=dwNum;
f.Close();
}
|
|
|
|
|
Haven't you a debugger, have you?
What are result of you inspection using the debugger?
What is the offending line, is it m_buffer=new char[dwNum]; ?
If the answer is Yes, then what is dwNum value?
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.
[my articles]
|
|
|
|
|
You have got WAAAAAY more patience than me.
I couldn't even see a question...
Iain.
|
|
|
|
|
Maybe patience it is context dependent. Anyway your reply to former Hakan D (now Mr. Surprise) was simply great.
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.
[my articles]
|
|
|
|
|
hi...
am using pocket oc 6.0.
i have to read a text file.
what is the procedure?
can anybody help me?
paulraj
|
|
|
|
|
I'm assuming you're using C++, as you're posting here. Reading a text file is the same on a normal PC as it is on a mobile PC. So, you're better writing a test program on the PC first, as that's easier to experiment with.
Look at CreateFile , ReadFile and CloseHandle functions.
But for more detailed help, you'll need to write more detailed questions.
Iain.
|
|
|
|
|
hi...
am using vc++ and pocket pc6.0.
am having a file like paul.doc.
and paul file condains { hi this is paul};
now i have to read the paul.doc and i have to store the datas in a string...
can anybody help me?
paulraj
|
|
|
|
|
In your first message, you said you had a text file. If you look on MSDN for the SDK functions I gave you, you can read data from a file.
Now, you say it's a DOC file. If this is still just a text file, look at my previous answer. If it's a Word document, then it's going to be a lot harder. Those files contain all sorts of things, (author info, fonts, bold etc) and not just the text.
What is the format of the text file?
If it is in word format, can you ask whoever is giving you this file to make it a friendlier format?
Iain.
|
|
|
|
|
its a doc file.
can you help me?
paulraj
|
|
|
|
|
Then it's gona be a lot harder. Google for Word automation and read tutorials about it. It's much too long to explain on a forum.
Can't you use a simple text file (.txt) ? That will be much easier.
|
|
|
|
|
|
What about using C++ ifstream class?
This is a very basic task, you can also check out some documentation samples, I suppose.
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.
[my articles]
|
|
|
|
|
CPallini wrote: you can also check out some documentation samples
Where do I get one of those?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|