|
More info please... Are you using ODBC, ADO, DAO???
John
|
|
|
|
|
At the moment i'm using MyODBC to connect to my database in MySQL.
|
|
|
|
|
|
My MFC app is using comboboxes with the CBS_DROPDOWN style (i.e. edit control + drop list). The combos are defined in a dialog template. I want to be able to switch these to CBS_DROPDOWNLIST style (i.e. static control + drop list).
My difficulty is that I need to change the style AFTER the comboboxes have been created.
(How) can this be done?
Andrew
|
|
|
|
|
m_pComboBox.ModifyStyle(...)
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hi Eugene,
I just tried your suggestion, but it doesn't work.
My combobox is derived from CComboBox, I have a member function to do the switch
void CMyComboBox::MakeStatic()<br />
{<br />
VERIFY(ModifyStyle(CBS_DROPDOWN, CBS_DROPDOWNLIST));<br />
}
I call MakeStatic() after the combo has been created, but immediately before I load the combo. The ModifyStyle() call returns TRUE - the VERIFY doesn't generate an error. I also tried ModifyStyleEx(), just in case, but it doesn't work either
|
|
|
|
|
Andrew Allen wrote:
I just tried your suggestion, but it doesn't work.
My combobox is derived from CComboBox, I have a member function to do the switch
void CMyComboBox::MakeStatic()
{
VERIFY(ModifyStyle(CBS_DROPDOWN, CBS_DROPDOWNLIST));
}
I've had this problem myself. What I did was create TWO combobox controls, one a dropdown and the other a dropdown list, and placed them right on top of each other. I used some other control to determine the state I wanted the "combo" in, and showed/hid the appropriate one.
Actually, I had this problem with CListBox. You can't change its selection style at runtime, either.
|
|
|
|
|
Yep, I'm convinced ModifyStyle() doesn't work after the control has been created. I just found this article talking about Listboxes,
http://www.codeproject.com/combobox/listbox_tut.asp[^]
...
Changing List box Styles at Runtime
It is not possible to change these styles at runtime even though ModifyStyle() may give the impression it does. If you want turn the Sort style on and off for example it is best to construct the List box by calling new and Create then deleting it and creating a new one when the style is to be changed. Alternatively you can have 2 List box superimposed and hide the one with the incorrect style.
I already thought about overlapping two controls, but I have about 10 in my dialog and at the time it seemed messy in the dialog template. Looks like that's what I'll do.
thanks for your help!
|
|
|
|
|
Can someone supply me the code required to iterate through a list of files in folders and sub-folders???
Using SDK calls, not MFC CFileFind class...
Thanks
I'm drinking triples, seeing double and acting single
|
|
|
|
|
This is what I use, but I'm looking into moving to the Boost::filesystem library to do platform independant directory iteration.
#include "io.h"
class CFileSpec : public _finddata_t {
long m_hfile;
public:
CFileSpec() {
m_hfile = -1;
}
~CFileSpec() {
if (m_hfile>=0)
_findclose(m_hfile);
}
bool First(const char* filespec) {
if (m_hfile>=0)
_findclose(m_hfile);
return (m_hfile=_findfirst((char*)filespec, this)) != -1;
}
bool Next() {
return m_hfile>=0 && _findnext(m_hfile, this)==0;
}
};
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
I'm not sure if thats really what I needed. What i'm looking for is how would you iterate a folder and it's sub-folders returning all the files until no more folders or files are left?
I"m confused about how to determine that when a directory has been found, what do you do then? Do files always preceed folders when searching?
Like if the directory i'm searching has has say 10 files and 3 folders each folder has 3 more sub folders. If on the third iteration I determine the file is actually a folder, do I open that folder then, and begin to add files that are in the folder, complete that and go back to where I left off???
Do I need a fancy stack to keep track of things?
Unless folders always come after or before files the code to traverse the file structure(required to fill a tree control with folders and files) must be very confusing????
I can't figure it out anyways...
Thanks
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Sorry, that was the code for a single directory, but it's not hard to extend it for multiple directories.
FileSearch.h
#include <string>
#include "FileSpec.h"
class IFileParser
{
public:
virtual void onFile(std::string str, std::string type) = 0;
virtual void onFilesDone() = 0;
virtual void onEnterDir(std::string str) = 0;
virtual void onExitDir(std::string str) = 0;
virtual ~IFileParser() {}
};
class FileParserAdapter : public IFileParser
{
public:
virtual void onFile(std::string str, std::string type) {}
virtual void onFilesDone() {}
virtual void onEnterDir(std::string str) {}
virtual void onExitDir(std::string str) {}
virtual ~FileParserAdapter() {}
};
class FileSearch
{
public:
FileSearch();
~FileSearch();
void findFiles(const std::string& path, const std::string& type, IFileParser& parser);
private:
void addFiles(const std::string& path, const std::string& type, IFileParser& parser);
};
FileSearch.cpp
#include "FileSearch.h"
using namespace std;
FileSearch::FileSearch()
{
}
FileSearch::~FileSearch()
{
}
void FileSearch::addFiles(const string& path, const string& type, IFileParser& parser)
{
CFileSpec spec;
string search = path + "\\" + type;
for (bool more=spec.First(search.c_str()); more; more=spec.Next())
{
if( !(spec.attrib & _A_SUBDIR) )
{
parser.onFile( spec.name, type );
}
}
}
void FileSearch::findFiles(const string& path, const string& type, IFileParser& parser )
{
parser.onEnterDir( path );
addFiles(path, type, parser);
parser.onFilesDone();
CFileSpec spec;
string search = path + "\\*.*";
string result;
for (bool more=spec.First(search.c_str()); more; more=spec.Next())
{
if( (spec.attrib & _A_SUBDIR) )
{
result = spec.name;
if( (result != ".") && (result != "..") )
{
result = path + "\\" + spec.name;
findFiles(result, type, parser );
}
}
}
parser.onExitDir( path );
}
Here's a sample usage to help with the renumbering of files 1.jpg - 01.jpg.
#pragma warning(disable:4786)
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <sstream>
#include "FileSearch.h"
using namespace std;
bool smart_comp(const string& a, const string& b)
{
if(a.length() != b.length())
{
return a.length() < b.length();
}
else
{
return a < b;
}
}
class WFileParserAdapter : public FileParserAdapter
{
public:
virtual void onFile(std::string str, std::string type)
{
files_.push_back(str);
}
virtual void onFilesDone()
{
cout << dirs_.top() << endl;
sort(files_.begin(),files_.end(),smart_comp);
for(int i = 0; i < files_.size(); i++)
{
string from = dirs_.top() + "\\" + files_[i];
ostringstream oss;
oss << dirs_.top() << "\\" ;
if(i+1 < 10)
{
oss << 0;
}
oss << i+1 << ".jpg";
string to = oss.str();
cout << from << " -> " << to << endl;
rename(from.c_str(),to.c_str());
}
files_.clear();
}
virtual void onEnterDir(std::string str)
{
dirs_.push(str);
}
virtual void onExitDir(std::string str)
{
dirs_.pop();
}
virtual ~WFileParserAdapter() {}
private:
vector<string> files_;
stack<std::string> dirs_;
};
int main()
{
FileSearch g;
vector<string> v;
v.push_back("*.jpg");
v.push_back("*.html");
v.push_back("*.txt");
string path = "C:\\";
g.findFiles(path, "*.jpg", WFileParserAdapter());
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
thanks
I'm drinking triples, seeing double and acting single
|
|
|
|
|
I am having problem creating a simple C++ MFC Application using Visual C++ .NET with database support. For database, I use ODBC and selected an Oracle table. Here is the error message:
Microsoft Development Environment
Error occurred while converting the wizard's text to the code page of the existing text in the file: C:\Excercise\db4\db4Set.h
However, if I select a desktop database, for example, a DBF file, the problem does not occur.
Eilzabeth
|
|
|
|
|
I need to catch file system updates for my directory tree
control - that is to say, if anything modifies the directory
tree while my user is browsing, I need to know so he gets
to see the updated view.
So, is there some kind of callback to say "let me know if
the filesystem changes and how" or is there a windows message
that I should be catching?
I know some apps you seem to have to hit Refresh (F5) to get
the system to pickup changes, but I've seen others that seem
to change on the fly and I assume a windows message or a callback was involved. I'm just a little lost on what to look in MSDN for...
|
|
|
|
|
|
*heh!*
Well, it's a nice solution. But it won't work for me. Target platform support is insufficient (I have to support good old
win98 in addition to 2K/XP). But this looks like the way one
would *prefer* to go if one had his druthers, I admit.
Thanks, another good post.
|
|
|
|
|
In that case use the good old fashioned timer and poll the directory structure checking the last time modified date of all the files if "my" solution is unavailbale by checking the OS version. You may be able to get away by just checking the sub directory date/time instead of all the files.
Or for 95/98 add a F5 refresh key!
Hopefully there won't be too many 95/98 systems around
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
start a thread the block it waiting for the hNotify handle to be valid
HANDLE hNotify = FindFirstChangeNotification(_T("C:\\Monitor_this_folder"), TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME |
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE);
while(g_bContinue)
{
WaitForSingleObject(hNotify, INFINITE);
PostMessage(ptr_lparam.hWnd, WM_EX_CHANGENOTIFICATION, 0, 0);
FindNextChangeNotification(hNotify);
}
FindCloseChangeNotification(hNotify);
I got this example from chapter 7 of Windows Shell programming, D. Espisito
you can download on amazon in PDF format
http://images.amazon.com/images/P/B000063UL1.01.LZZZZZZZ.jpg[^]
There's no more in print, yet I have a hard copy!!!
|
|
|
|
|
Beer said:
start a thread the block it waiting for the hNotify handle to be valid
HANDLE hNotify = FindFirstChangeNotification(_T("C:\\Monitor_this_folder"), TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME |
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE);
Tomb replies:
I'd seen that function.... so it seems my suspicion is confirmed. Will this notify you of changes in subdirs? (ie if I set it for c:\\* (root folder), will it notify of changes in any child dir? or do I have to somehow monitor every folder concurrently (and if so, is there a good way to do this as a whacking pile of threads might not be an ideal choice.... maybe some sort of multiple object wait?)
This looks like what I'm wanting thought.
Thanks muchly.
|
|
|
|
|
kaladorn wrote:
Will this notify you of changes in subdirs? (ie if I set it for c:\\* (root folder), will it notify of changes in any child dir?
Yes, it will, you really should just buy Dino's book, it's full of good stuff.
I'll even let you in on how I got a hard copy of it even though it's out of print!
I bought it used from one of those amazon.com used book dealers. It only cost me thirty bucks too!
If you do any type of shell programming targeted at win98->XP, this book is a must have, you will end up using it for countless numbers of things.
|
|
|
|
|
I'll hunt for the book. I always like buying books that have lasting value and a solid testimonial from someone in the field helps convince me (where I haven't personally seen or leafed the book). I just hate shelling out money for books that quickly obsolesce.
Thanks again!
Tomb
|
|
|
|
|
|
PS: in that example of his you have to type the path of a folder in the edit box, or it the empty field will cause it to crash.
|
|
|
|
|
can anyone help with this function parameters, i cant get them at all
"AdjustTokenPrivileges"
|
|
|
|