|
- Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
- Have you verified your
FindItem call is successful with a non-virtual/non-owner data list control?
Aside from that, can't see as you're doing anything wrong
|
|
|
|
|
Hi and thank you for the help!
I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:
<00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
<00005> 00070E74 R LVM_FINDITEMA iIndex: 86
I really don't know why my message handler is not called
Niki
|
|
|
|
|
I know what is my error:
FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position.
Is there a way to implement this?
I already tried UpdateWindow() and also SetSelectionMark()...
Thank you!
|
|
|
|
|
That I can help you with
CListCtrl::EnsureVisible makes a specified item visible. CListCtrl::Scroll gives you more control over how the list control's view is altered.
|
|
|
|
|
Using Graphics DrawImage method am drawing a PNG image on button,it displays once but it is not sustaining when mouse moves on the button
|
|
|
|
|
Are you sure you have the right forum? This is for unmanaged C++.
It sounds like you might want the C# forum.
|
|
|
|
|
|
Show code,please?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Probably you're writing the button in the wrong message handler (if it is a message handler).
As already suggested by Hamid, you should post some code to obtain help.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
kiranin wrote: but it is not sustaining when mouse moves on the button
That is not a surprise. The button redraws itself when it is hovered over, clicked on, not clicked on, when it's just plain spiteful...
You need to put the drawing code in the right place.
Search the articles on codeproject for owner draw buttons. (http://www.codeproject.com/KB/buttons/[^]) and replace their drawing code with your own PNG stuff.
You may even find a PNG drawing button already done.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
Where to best store a global object in an SDI app? In my case it's a "DatabaseManager" class for accessing an SQLite database.
First it was just a member variable of my CDocument but now I need the object in many places in my app.
So where to best store it?
* Global variable?
* Singleton object?
* Member variable of CWinApp?
* ...
One problem: I want to open the database when constructing the object, so the object may throw an "DatabaseException". For this reason a global variable as well as a singleton seem to be suboptimal to me.
Niki
|
|
|
|
|
The "member variable of CWinApp" makes the most sense to me.
HTH
|
|
|
|
|
Ok
Is it a good way to store the "DatabaseManager" class as a pointer and do a new CDatabaseManager(filepath) inside my CMyApp::InitInstance() (and an appropriate delete in the destructor)?
And then everytime I need it, just
dynamic_cast<cmyapp*>(AfxGetApp())->GetMyDatabase()
?
Thank you,
Niki
|
|
|
|
|
...or is it better to write a
extern CMyApp theApp;
in every source file needed and use theApp.GetDabataseManager() ?
|
|
|
|
|
From a strict technical viewpoint, this solution is faster to execute, and cleaner, because there is no cast involved.
I would prefer this, personally.
|
|
|
|
|
nobaq wrote: First it was just a member variable of my CDocument but now I need the object in many places in my app.
That's what the GetDocument() method is for.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I have learned c++/MFC for several years but no obvious improvement.
suddenly I transfered to c# and .net, I have strong feeling that c# can save you much much more time compared to MFC based programming.
I am wondering why MFC is still being used now? what is the advantage? is it efficiency or flexbility compared to c# based programming?
|
|
|
|
|
I think compare is not correct but for me c++ is best language to use to write COM components also you can see we dont need to write lot of code for use of windows API but on the C# you need to more work on the C# you cant use of multiinheritance(I like it myself) on the C# you dont have header file and....for example I read a programmer said that F# is better C#.
F# code:
#light
(*sample windows forms program*)
open System.Windows.Forms
let form=new Form(Visible=true,TopMost=true,Text="Welcome")
...
...
<joke>
BTW be careful you are on the c++ form and you want to compare c++?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Seraph_summer wrote: I have strong feeling that c# can save you much much more time compared to MFC based programming.
Care to elaborate?
|
|
|
|
|
Diversity is a good thing
.net is good, but it is far from perfect. It might be easier to learn than MFC, but that doesn't mean that thousands of MFC programmers are going to switch to .net. They already *know* MFC, there is not much need for them to switch to anything else.
I've used both, and I still prefer C++/MFC than C#/.net for simple projects.
But C#/.net is my choice when I work with databases.
As I said it is about diversity, everyone pick what he/she likes.
|
|
|
|
|
Seraph_summer wrote: I have strong feeling that c# can save you much much more time compared to MFC based programming.
For some things, the .NET framework is very useful and, obviously, well integrated with C#. However - if you expand your horizons outside Microsoft, you can find a lot of useful, well written libraries for C++ - Boost[^], libxml2[^] and many others - I've done a few comparative implementations in both C# and C++ and have found the development time and size of the app to be comparable (and very dependent on using the right libraries) between the two languages, while the C++ implementations have been consistently faster.
Of course, the apps I'm writing aren't just GUI + database layer, so my results may have no resemblance to what might hold in your domain.
|
|
|
|
|
Depends on what you're doing...
If you're writing something that is low-level, or efficiency and response time is very important, you would write C++ (unmanaged...).
Just think of a 3D computer game written in .Net, it'll be so slow that people just won't use it (or the requirements would be sky-high!).
Same for massive web-severs and such...
I also use C#, but only or Win Forms and such... It does cut the development time, saving many hours!
So both are good - just depends for what...
|
|
|
|
|
I am writing a small article about file enumeration, and in one of my CppUnit test I *discovered* that FindFirstFile/FindNextFile won't correctly report file attributes on FAT32 and FAT16. Specifically, FILE_ATTRIBUTE_TEMPORARY attribute is the problem here:
Here is what my code does:
SetFileAttributes(sTestFile.c_str(), FILE_ATTRIBUTE_TEMPORARY);
DWORD attr_1 = GetFileAttributes(sTestFile.c_str());
FindFirstFile(sTestFile.c_str(), &fd);
It took me nearly a day to realize that problem is due to File system and not my code. And now after spending hours going through on-line documentation I decided to ask here:
1. Is this documented behavior or a bug?
2. Am I doing something wrong in my code. Maybe it is something about temporary files that I failed to take into account.
Any help would be highly appreciated. I have tested this on two computers, both running XP, and I get same results on both.
Finally, here is a simple console project that demonstrates the problem:
#include "tchar.h"
#include "Windows.h"
#include <string>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
basic_string<tchar> sPath = _T("");
basic_string<tchar> sTestFile = _T("\\test_file.txt");
TCHAR root[256] = {0};
DWORD size = 256;
WIN32_FIND_DATA fd;
if (::GetCurrentDirectory(size, root) != 0)
sPath = root;
else return 1;
sPath += sTestFile;
CreateFile(
sPath.c_str(),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY,
NULL);
_tprintf(_T("\nA file %s is created...\n"), sPath.c_str());
_tprintf(_T("\nFile attributes (as reported by GetFileAttributes() ) are now: %x \n"), GetFileAttributes(sPath.c_str()));
_tprintf(_T("\nExplicitly set FILE_ATTRIBUTE_TEMPORARY attribute...\n"));
SetFileAttributes(sPath.c_str(), FILE_ATTRIBUTE_TEMPORARY);
_tprintf(_T("\nFile attributes (as reported by GetFileAttributes() ) are now: %x \n"), GetFileAttributes(sTestFile.c_str()));
FindFirstFile(sTestFile.c_str(), &fd);
_tprintf(_T("\nAccessing file with FindFirstFile()...\n"));
_tprintf(_T("\nFile attributes (as reported by FindFirstFile() ) are now: %x\n"), fd.dwFileAttributes);
DeleteFile(sPath.c_str());
_tprintf(_T("\n\n// copied from winnt.h\n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_READONLY 0x00000001 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_HIDDEN 0x00000002 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_SYSTEM 0x00000004 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_DEVICE 0x00000040 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_NORMAL 0x00000080 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_OFFLINE 0x00001000 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 \n"));
_tprintf(_T("//#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 \n"));
return 0;
}
</tchar></tchar></iostream></string>
modified on Saturday, January 10, 2009 3:38 PM
|
|
|
|
|
Hi,
it has been a long time I used it, but here is what I remember:
1. CreateFile creates a file, opens it and returns a handle to it;
2. when you are done, you must call CloseHandle;
3. file data and metadata (such as last write time, and the flags) is only guaranteed to be committed
to disk when the file got closed.
Issue 3 is what allows different file systems to behave slightly differently.
Also I don't expect FindFile to keep track exactly of what is happening with open files.
Hence I suggest you set the files the way you want them, make sure they are all closed, and only then
observe in any way you see fit, including enumeration through FindFile.
|
|
|
|
|
Thank you for your answer, I guess I was to hasty to post my question (and the fact that I went to bed at 4:30 AM last night certainly didn't help). I forgot to say that I removed all error checking and file handles because it did not affect my problem, and I wanted a simplest/shortest possible test.
The same thing happens even if file handle is closed (I even tried calling ::Sleep(5000) right after CloseHandle, just to be sure (I was also desperate ).
Basically, my Unit test goes through a loop of all possible file attributes, it creates a new file, sets one Attribute and checks if my enumeration class finds the file. If it does, test is successful, and loops goes to test another Attribute.
And all is fine until FILE_ATTRIBUTE_TEMPORARY is tested, and only if I start tests on my USB drive (which is FAT32 based), on my hard drive test works fine.
You had a very good idea, but unfortunately that is not it
Best regards,
loreia
|
|
|
|