|
I like Rational Purify
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Here is a link to Fortify. I believe it is free.
Also, VC++ has fairly good built-in facilities. Check MSDN for articles on this topic.
|
|
|
|
|
Rick York wrote:
Here is a link to Fortify
Thanks. I was lookin for a free tool too...
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
hi there. I have a text box that holds a string, i want to have a button so that when you press it, the string in the textbox is added to the list box. Can some please help me
Greatly Appreciated.
|
|
|
|
|
See the documentation on CEdit and CListBox . There are methods to get the string from an edit control and add it to the list box. I was tempted to write the few lines of code for you, but I'd be doing you a disservice by not putting you on the right track instead.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
No you can't...
You see, another process doesn't have access to the memory you are passing to SendMessage. You are actually lucky your SendMessage isn't crashing the other application.
Now some messages such as WM_GETTEXT have code inside of GDI32 or USER32 (whatever) that handle this case for you. But, most messages don't have this. Generally, you shouldn't be sending messages to other application unless the message has been specifically designed to support inter-process sends.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi Im trying to override the equal_range method in a class
inherited from multimap so it is non case sensitive:
#include <algorithm>
#include <string>
#include <map>
typedef std::pair<std::string, void *> Range_t;
typedef std::multimap<std::string, void *> MyMap;
typedef MyMap::iterator MyMapIterator;
bool nocase_compare(Ranger a, const Ranger b) { return a.first < b.first; }
class AMap : public MyMap {
Range_t equal_range(MyMapIterator start, MyMapIterator stop, const std::string& key) {
return std::equal_range(start, stop, key, nocase_compare);
}
};
int main()
{
AMap m;
}
But I just cant get the nocase_compare to match what equal_range needs. Help someone?
help
|
|
|
|
|
Try with bool nocase_compare(const Ranger& a,const Ranger& b) .
Also, *start and *stop must be of the same type as key (which they are currently not, I think).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have come across an interesting problem. I have a Resource only DLL which contains only string tables in about 7 languages. Using the resource editor I can confirm that the Dll is built correctly.
In InitInstance of my app I call LoadLibrary and save the returned handle. ( m_hInstDLL )
The I added a function for extracting the strings. This is when the fun starts.
This code works and returns the string from the default language table.
HINSTANCE hInst = AfxGetResourceHandle();
CString theString;
AfxSetResourceHandle( m_hInstDLL );
theString.LoadString( IDS_TESTDTRING );
AfxSetResourceHandle( m_hInst );
However if I use the FindResource or FindResourceEx functions they fail as in the following code.
HINSTANCE hInst = AfxGetResourceHandle();
CString theString;
AfxSetResourceHandle( m_hInstDLL );
theString.LoadString( IDS_TESTDTRING );
HINSTANCE hInst2 = AfxFindResourceHandle(MAKEINTRESOURCE(IDS_TESTSTRING), RT_STRING);
HRSRC hRes = ::FindResource(hInstDLL,MAKEINTRESOURCE(IDS_TESTSTRING), RT_STRING);
......
AfxSetResourceHandle( m_hInst );
The interesting thing is that AfxFindResourceHandle returns the same value as hInstDLL, as it should. This means that AfxFindResourceHandle finds the string resource. FindResource on the other hand returns 0.
Calling FindResourceEx with the appropriate language code also returns 0.
What makes this even more confusing is that in searching through MSDN it is stated that AfxFindResourceHandle actually calls FindResource.
Ideas anyone? It must be possible to make it work.
Happy programming!!
|
|
|
|
|
AfxSetResourceHandle( m_hInstDLL );
theString.LoadString( IDS_TESTDTRING );
HINSTANCE hInst2 = AfxFindResourceHandle(MAKEINTRESOURCE(IDS_TESTSTRING), RT_STRING);
HRSRC hRes = ::FindResource(hInstDLL,MAKEINTRESOURCE(IDS_TESTSTRING), RT_STRING); This might be an absolutely irrelevant question, but have you noticed you're using two variables m_hInstDLL and hInstDLL ? Do they store the same value?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That is a typo in here, it is actually m_hInstDLL.
Happy programming!!
|
|
|
|
|
I found 2 issues in ATL 7.0 (code in atlbase.h) regarding services. I may or may not be right, some of you will tell me if I'm not. Here they are:
1- A service with no COM interface refuses to start
When creating a service, and you don't define any COM object in it (let's say you want to write a service in ATL, but don't have any use of a COM server in it), it won't start with the SCM reporting that it refuses to start without returning an error code.
This is because of the call to RegisterClassObjects in CAtlExeModule<T>::PreMessageLoop() . When there is no object to register, this method returns S_FALSE . In the CAtlServiceModule<T>::Run() method, there is a line that says:
if (hr == S_OK) {
}
The problem with that is that hr = S_FALSE . Replace with the following:
if (SUCCEEDED(hr)) {
}
Some may argue that there is no point in having a service not exposing a COM object. To those I say "hey, COM is not the only thing that a server could implement". Heh. And I like to write services using ATL because it is easy.
2- Multithreaded service
If you write a service containing objects with the "free" threading model, you may want to change the _ATL_APARTMENT_THREADED define to _ATL_FREE_THREADED in stdafx.h . I can tell you upfront that your service will start but you won't be able to activate any of the COM objects in it.
The problem is with the m_bDelayShutdown member variable in CAtlExeModule<T> , from which CAtlServiceModule<T> derives. In CAtlServiceModule<T>::ServiceMain , this member is set to false , probably because it is irrelevant (and maybe harmful, who knows) in a service.
This generates a problem in CAtlExeModule<T>::PreMessageLoop . Look at this snippet from the function:
hr = pT->RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
if (FAILED(hr))
return hr;
if (hr == S_OK)
{
if (m_bDelayShutdown)
{
CHandle h(pT->StartMonitor());
if (h.m_h == NULL)
{
hr = E_FAIL;
}
else
{
hr = CoResumeClassObjects();
ATLASSERT(SUCCEEDED(hr));
if (FAILED(hr))
{
::SetEvent(m_hEventShutdown); ::WaitForSingleObject(h, m_dwTimeOut * 2);
}
}
}
if (FAILED(hr))
pT->RevokeClassObjects();
}
else
{
m_bDelayShutdown = false;
}
NOTE: This code is only available with _ATL_FREE_THREADED defined.
As your keen eye may have noticed (see the bolded lines of code if not), the RegisterClassObjects method is called with the REGCLS_SUSPENDED flag. This requires a call to CoResumeClassObjects in order for a client to be able to activate an object from your exec.
If you read the code carefully, this method is never called if m_bDelayShutdown is set to false . What I did is simply override the PreMessageLoop method (tell me if you don't know how to do it), and modify it as follow (see bolded line of code):
hr = pT->RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED);
if (FAILED(hr))
return hr;
if (hr == S_OK)
{
if (m_bDelayShutdown)
{
CHandle h(pT->StartMonitor());
if (h.m_h == NULL)
{
hr = E_FAIL;
}
else
{
hr = CoResumeClassObjects();
ATLASSERT(SUCCEEDED(hr));
if (FAILED(hr))
{
::SetEvent(m_hEventShutdown); ::WaitForSingleObject(h, m_dwTimeOut * 2);
}
}
} else {
hr = CoResumeClassObjects();
}
if (FAILED(hr))
pT->RevokeClassObjects();
}
else
{
m_bDelayShutdown = false;
}
This will make your objects available to the outside world.
------------------------------------------------------------------------------
I don't know if I'm right or not, but it resolved some issues for me. If some of you find that what I'm saying is completely dumb, please demonstrate.
Tx for listening
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Write an article describing these issues. Your post in VC++ board will soon become old and nobody (ok, *almost* nobody) will be able to find it.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello,
I'm having a problem with the CFileDialog class in a UNICODE build. I'm overriding the OnFileNameOK function, and upon entering the function, I'm finding that the nFileOffset and nFileExtension variables in the OPENFILENAME struct have not been set (or were set to 0) after DoModal called GetSaveFileName. The rest of the struct is filled out appropriately, and it is clear that nFileOffset should be a non zero value. In a non unicode build, the variables are set correctly. Am I missing something? Any help would be greatly appreciated.
Thanks,
SQ
|
|
|
|
|
Can you show some snippet of the offending code? Are you sure you haven't forgot some _T (or TEXT ) somewhere? How do you check the value of those parameters (OutputDebugString , debugger watch, other)?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I can see the same behavior in an otherwise empty project that has a class CFDialag derived from CFileDialog, with one overridden function OnFileNameOK. I set a breakpoint at the top of OnFileNameOK and call:
CFDialog saveAsFileDlg(FALSE,NULL,NULL,OFN_EXPLORER,NULL,AfxGetMainWnd());
saveAsFileDlg.DoModal();
After entering a filename in the dialog box and clicking OK, the breakpoint hits and the ofn.nFileOffset variable is 0. The same virtually empty project compiled without UNICODE correctly sets the nFileOffset variable to 11 (the number of characters in the selected path).
-SQ
|
|
|
|
|
Excuse me for asking the obvious, but are you trying your project in a Unicode-enabled platform (NT 4.0/2000/XP)?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, I'm using 2000. All of the other UNICODE functions seem to be working correctly...
-Scott
|
|
|
|
|
Hi
could you help me who to print text in "Arial CE" 12px ? ( in map mode MM_HIMETRIC).
I use CFont::CreateFontIndirect, but I don't which font size have to I set.
Wiizi
|
|
|
|
|
Use CreatePointFont or CreatePointFontIndirect and pass the printer DC.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Previous answer assumes that you're going to create 12 point font. However, px from your post suggests pixels. 12 pixels on the printer is too small - you'll get little rectangles instead of words.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sorry, I need print font which has same size as on all printers.
Wiizi
|
|
|
|
|
OK - that's why you need to express the font size in points. CreatePointFont[Indirect] will do the job nicely.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
what is the importants of learning the bitwise command? Does it come in handy latter on in programming? "Its slightly comfusing," But if it is an important thing to learn, i dont mind learning it, vise versa.
Thanks all
~SilverShalkin
Rose tip dew berries, surounds the warmth of deference realms.
Lead the life in fantasy. Where life at end is life just starting.
|
|
|
|
|
Ever worked with window styles?
Any time you have to deal with a bit mask, you will have to use the bit operators.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|