|
ctrl.SetItemState(index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
Roger Allen
Sonork 100.10016
Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.
|
|
|
|
|
You can use CListCtrl::SetItemState
for example: SetItemState(index, LVIS_SELECTED, LVIS_SELECTED);
|
|
|
|
|
Thank you, guys
|
|
|
|
|
Hi,
I have to bite the bullet and provide a custom container class*
Broken down, here's my question:
Assume a typical array implementation with size/reserve mechanism, or an allocation granularity.
if the vector contains classes is it better to
a) allocate the "additional" elements the normal way, thus calling the default constructor immediately even for the currently unused elements
b) allocate "dumb" memory, and call the constructor explicitely (using placement new) only when an element gets into use.
(a) has lesser complexity, and less pitfalls.
OTOH, (b) is closer to a "simple containter", in that it calls only the constructor of elements that are really used (better encapsulation of the preallocation mechanism), and it might perform better in an reserve-and-append scenario: data can be appended in one pass calling copy constructors, rather than two passes (1st pass default CTor, 2nd pass assignment operator).
Comments? Ideas? Experiences?
*) STL is out for several reasons, and this time it's not because I hate STL
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
sighist | Agile Programming | doxygen
|
|
|
|
|
I have a number of template collection class' and use method (b) ... and method (a).
I have a bit flag(s) in my class that tracks if i'm to call the constructor and/or destructor (along with methods to set these flags of course).
If your container class is specificly for a known containee class then no worries.
If the container is a template class for any containee type (base type or class) then there are a couple things that are a pain :
- you will want to control if the container calls contructor/destructor as mentioned above.
- you can't use #defines or template versions of contructor/destructor (see below).
- ummm, some other stuff ...
// Placement new :
// The #define versions work for all types except when trying to destruct
// a base type (e.g. long).
// The template version work for all types, but can introduce more code.
// The compiler recognizes there is no destructor for base types and inserts
// a no-op function.
// The biggest problem with constructor template is that can not pass
// variable parameter list to constructor.
// Note the #define version has been left so that the parameter list
// can be tacked on.
//
#define CK_CONSTRUCTOR(TT, PTR) new(PTR) TT
#define CK_DESTRUCTOR(TT, PTR) ((TT*)(PTR))->~TT()
template<class tt=""> inline void FkConstructor ( TT *PTR ) { new(PTR) TT(); }
template<class tt=""> inline void FkDestructor ( TT *PTR ) { PTR->~TT(); }
so i end up calling FkConstructor/FkDestructor in my container (you could use CK_CONSTRUCTOR() instead).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I have developed a mutithreaded FTP application for uploading more than one files simultaneously. I have used MFC's CFTPConnection class for establishing connection and for transferring files. For every file, i have to transfer i connect to the FTP server using GetFTPConnection and then transfer file using PutFile. But after uploading few files CPU usage shoots up to 100%. Can any body tell me the reason for this.Sometimes it does not last long but sometimes it lasts long and the application hangs. Currenltly 5-6 threads are active at a time and other that this there is one more thread running in my application to chck the FTP connection is axctive or not.
|
|
|
|
|
The most likely cause for 100% CPU is that you have a runaway thread that is not correctly waiting, is stuck in an infinite loop, infinite recursion, or something like that which causes it to use all the CPU. Place a few TRACE statements in the threads and one of them will go mad with output - thats your culprit!
|
|
|
|
|
I saw the sample program of how to print out in a formview.
The code is following. Right now I want to print out the image
to fit into paper( if A3 larger image than A4). How to achieve this?
CPoint oldPoint = GetScrollPosition( );
CPoint pt( 0, 0 );//scroll to up
this->ScrollToPosition( pt );
CClientDC dc(this);
CRect rect;
m_dib.Attach( GDIUtil::GrabDIB( &dc, rect ) );
ScrollToPosition( oldPoint );
|
|
|
|
|
i use following code
#include <Iads.h>
#include <Adshlp.h>
#pragma comment(lib, "ActiveDS.Lib")
#include <COMDEF.H>
bool CheckUserADSI(const char* parUserName, const char* parCode)
{
IADsOpenDSObject* pObject = NULL;
IDispatch* pDisp = NULL;
bool RetValue = false;
HRESULT hr = S_OK;
_bstr_t UserName (parUserName);
_bstr_t Code (parCode);
hr = ADsGetObject(L"LDAP:", IID_IADsUser, (void**) &pObject);
if (SUCCEEDED(hr))
{
hr = pObject->OpenDSObject(L"LDAP://net.blum",UserName, Code, ADS_SECURE_AUTHENTICATION, &pDisp);
pObject->Release();
if (SUCCEEDED(hr))
{
RetValue = true;
}
}
pDisp = NULL;
pObject = NULL;
return RetValue;
}
when i compile the code, the compiler says:
WinLogon.obj : error LNK2001: unresolved external symbol _IID_IADsUser
Any ideas how to solve this problem ?
I've checked the platform SDK samples.. all are using this IID.. but i haven't seen a single include or lib file they were linking..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
#include <activeds.h>
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
guess you forgot to use the <> - Tags.. so your include got stripped..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
#include <activeds.h> is there, you just have to look real close!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
use "__uuidof ( expression )", where "expression" is interface name ie "IADsUser".
The chosen One
|
|
|
|
|
How to print from the Dialog Box?
Hello!
I have come across some problem hope some one could help me out..
I have got a MFC based dialog box on which i have various controls liek edit boxes, static labels and pushbuttons. For one of the push button say whose caption is "PRINT" i have given the functionality of Printing the same dialog box. I need the dialog box to be printed as is when i click the print button. So what the code should contain and my approach is as follows...
void PrintTest:nPrint()
{
CDC dc;
CPrintDialog dlg(FALSE);
//dlg.GetDefaults();
if(dlg.DoModal() == IDOK)
dc.Attach(dlg.GetPrinterDC());
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T ("print this dialog");
dc.StartDoc(&di);
return;
}
Is my approach correct. I have a doubt, how do i get the dialog handle or the device context i mean the dialog's context so that i can pass the same to the printfunction.
Venky
|
|
|
|
|
See if these two articles give you any pointers:
http://flounder.com/printbitmap.htm
http://flounder.com/screencapture.htm
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How to print from the Dialog Box?
Hello!
I have come across some problem hope some one could help me out..
I have got a MFC based dialog box on which i have various controls liek edit boxes, static labels and pushbuttons. For one of the push button say whose caption is "PRINT" i have given the functionality of Printing the same dialog box. I need the dialog box to be printed as is when i click the print button. So what the code should contain and my approach is as follows...
void PrintTest:nPrint()
{
CDC dc;
CPrintDialog dlg(FALSE);
//dlg.GetDefaults();
if(dlg.DoModal() == IDOK)
dc.Attach(dlg.GetPrinterDC());
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T ("print this dialog");
dc.StartDoc(&di);
return;
}
Is my approach correct. I have a doubt, how do i get the dialog handle or the device context i mean the dialog's context so that i can pass the same to the printfunction.
Venky
|
|
|
|
|
http://www.codeproject.com/dialog/msgboxdemo.asp?df=100&forumid=1419&exp=0&select=632516#xx632516xx
According to the above, I created a MFC-AppWizard exe project(Dialog-based) and added the files "timedmsgbox.cpp" and "timedmsgbox.h" to it,then changed the afximpl.h path as: #include "C:\\Program Files\\Microsoft Visual Studio\\VC98\\MFC\\SRC\\afximpl.h"
My computer's OS is WindowsXP sp2
Compiling tool is VC6
The compiling result is like the below
How can I solve these problems?
Compiling...
timedmsgbox.cpp
d:\projects\timedmsgboxtest\timedmsgbox.h(44) : error C2146: syntax error : missing ';' before identifier 'm_sectMap'
d:\projects\timedmsgboxtest\timedmsgbox.h(44) : error C2501: 'm_sectMap' : missing storage-class or type specifiers
D:\projects\TimedMsgBoxTest\timedmsgbox.cpp(28) : error C2039: 'm_sectMap' : is not a member of 'CDlgTimedMessageBox'
d:\projects\timedmsgboxtest\timedmsgbox.h(23) : see declaration of 'CDlgTimedMessageBox'
D:\projects\TimedMsgBoxTest\timedmsgbox.cpp(28) : error C2146: syntax error : missing ';' before identifier 'm_sectMap'
D:\projects\TimedMsgBoxTest\timedmsgbox.cpp(28) : error C2501: 'CCriticalSection' : missing storage-class or type specifiers
D:\projects\TimedMsgBoxTest\timedmsgbox.cpp(28) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
TimedMsgBoxTest.exe - 6 error(s), 0 warning(s)
|
|
|
|
|
Add <afxmt.h> to your StdAfx.h header file, then Rebuild All.
|
|
|
|
|
It work well now
Thank you!
|
|
|
|
|
Hi,
I hope you have solved the current problem as replied by Mike.
When u get error as above, "error C2501: 'CCriticalSection' : missing storage-class or type specifiers", immidiately search "CCriticalSection" on MSDN.
There you will get header file u need to include.
Compiler follows set of instructions. If u forget including header files, it will throw error like above. Error numbers reported by VC compilers are described in detail on MSDN.
If u get compiler concepts clear, u will never face problem in solving such errors.
The chosen One
|
|
|
|
|
Great!
What a good lesson!
I don't know what to do about these errors before.
Thanks a lot for both of you!
|
|
|
|
|
I'm trying to extract Thumbnail images of files.
I've used IExtractImage and it works great, except that when it gets to internet shortcuts, it hangs for a long time (10-20 seconds) and always fails.
<br />
TCHAR path[MAX_PATH];<br />
DWORD priority = 0;
DWORD flags = IEIFLAG_ASPECT;
HBITMAP handle = NULL;<br />
CSize requestedSize(75,56);<br />
<br />
if (S_OK == imageExt->GetLocation(path, MAX_PATH, &priority, &requestedSize, 32, &flags))<br />
{<br />
hr = imageExt->Extract(&handle);<br />
<br />
if (S_OK == hr)<br />
{<br />
item->thumbnail = new CMyBitmapFromHandle(handle);<br />
}<br />
}<br />
<br />
imageExt->Release();<br />
I've tried various flags like with or without IEIFLAG_OFFLINE but nothing makes it work.
Does anybody spot the problem ?
Thanks
|
|
|
|
|
Originally, I had a 'struct' in a file along with other 'structs'. Then I added a new class to the program and because this particular 'struct' seemed so well suited with this new class, I moved the 'struct' into the same file with the new class.
Now, even though the file in which the new class is located, has the '#ifndef (etc.)' macro/preprocessor statement, the program will not compile and link due to a LNK2005 error.
The new class is being '#included' in several different class files, and the compiler is not complaining about the new class being multiply defined. Why is the 'struct' the problem?
Thanks for any insight.
William
Fortes in fide et opere!
|
|
|
|
|
Visual C++ sometimes fails to compute dependencies correctly, so you could have a stray definition in an object file from before the move. Try a Rebuild All.
Otherwise, I don't think it's possible to give guidance without seeing the header (so long as it isn't too long - trim out any private implementation and check that the error still occurs) and the exact error message.
|
|
|
|
|
Thanks for replying. (Of the others that have been posted, your's make the most sense.)
Here's the code for the struct file:
#idndef STRUCT_H
#define STRUCT_H
struct FirstStruct
{ etc. };
struct SecondStruct
{ etc. };
...
struct ThisStruct
{ etc. };
#endif // STRUCT_H Here's the file containing the new class:
#idndef HDR_H
#define HDR_H
struct ThisStruct
{ etc. };
class NewClass
{ ctor; dtor; etc. };
#endif // HDR_H Clearly it's a Visual C++ misdoing, because there's no C++ syntactical error involved, and if I were to put the 'struct' back to where it was originally located, the program compiles and links well. Then if I were to replace it back with the new class again, the linker acts up and produces the error. Next, if I were to comment out the 'struct' (where it exists in the file with the new class) it compiles and links well. It's ONLY when it appears openly (but separately and apart) from the new class, that the LNK2005 error message reappears.
Of the many situations I tried in getting it resolved, more than half of them involved doing a total "Rebuild all", but the problem still persist.
Yes, I've also deleted the ".ncb" file and a few others too, followed by a "Rebuild all". No difference.
William
Fortes in fide et opere!
|
|
|
|