|
Yes, I have the following Function wich calls the BROWSEINFO API, but when I run this on Win98 I get an exception, but on winME everything works OK. Can somebody help me solve this problem.
BOOL folderDialog(const HWND parent, const char *topic, char *result, const bool allowNew, const int extraFlags)
{
// CoInitialize must be called to support BIF_USENEWUI.
OleInitialize(NULL);
LPMALLOC pMalloc = NULL;
LPITEMIDLIST pidl = NULL;
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
// set the bi's default values
bi.hwndOwner = parent;
bi.lpszTitle = topic;
bi.ulFlags = BIF_STATUSTEXT | extraFlags;
if (!allowNew)
{
bi.ulFlags = bi.ulFlags;
}
pidl = SHBrowseForFolder(&bi);
if(pidl != NULL)
{
SHGetPathFromIDList(pidl, result);
// free memory
if (FAILED(SHGetMalloc(&pMalloc)))
{
throw "SHGetMalloc Failed!";
}
pMalloc->Free(pidl);
pMalloc->Release();
OleUninitialize();
return (BOOL)strlen(result);
}
OleUninitialize();
return FALSE;
}
|
|
|
|
|
Check the MSDN. One or more of the functions you are calling may not be implemented by the Win98 shell.
Gary R. Wheeler
|
|
|
|
|
While testing my application (a Win32 dll using WTL/ATL not a COM server, that exports functions to a mfc app) on Win98 I have had the following problem.
Under Windows XP/ Win 2000 the following works fine, and as expected
if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd) == TRUE){
_sError.Format("%s %d", "Showing page ", pPage->m_nPageID);
::MessageBox(NULL, _sError,"",MB_OK);
pPage->EnableWindow(TRUE);
pPage->ShowWindow(SW_RESTORE);
bResult = pPage->OnSetActive();
}
however under win 98, ::IsWindow always returns FALSE, regrdless.... has anyone a workaround for this as (I think?) it adds a bit more safety. I have even tried pPage->IsWindow(), but this also fails
Anyone had similar problems?
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
I don't really think this is the problem, but it costs nothing to give it a try: replace your check with
if(pPage->m_hWnd != NULL && ::IsWindow(pPage->m_hWnd)){
... Note the docs say the result on success of IsWindow is nonzero, which is not the same as being equal to TRUE .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thnaks, this did the job, but why did my function work on NT4/2000/XP. but on Win98 (and I presume on Win95) not, this was what confused me......?
Thnaks once again
Grüß Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
The docs say that ::IsWindow() returns non-zero if the argument is a valid window. In one case, the O/S returns TRUE. In another case, the O/S is returning (possibly) the window handle, or something else, that is non-zero.
As a rule, the following:
BOOL condition = ::Windows_API_Call(...);
...
if (condition) {
...
}
is preferable to
if (condition == TRUE) {
...
}
since the Windows API (where BOOL is defined) tends to play fast-and-loose with BOOL return values. Often, they define the return value of an API call as BOOL (which you assume has only two values, TRUE and FALSE), when it would be better to specify it as a DWORD. The return value in that case means one thing when it is non-zero, and something else when it is zero.
Gary R. Wheeler
|
|
|
|
|
I have this code wich creates a Grid, this works using a wrapper class.
CdxDBGrid m_grid;
m_grid.Create(_T("TestGrid"),WS_CHILD|WS_VISIBLE, CRect(1, 2, 3, 4), this,
1);
So the question How do I achive the same as above but with a pointer. Or how do I create a View with my pointer.
IdxDBGridPtr m_pGrid
|
|
|
|
|
<br />
CdxDBGrid *m_pgrid;<br />
<br />
m_pgrid = new CdxDBGrid;<br />
if (!m_pgrid)<br />
{<br />
return error;<br />
}<br />
<br />
m_grid->Create(_T("TestGrid"),WS_CHILD|WS_VISIBLE, CRect(1, 2, 3, 4), this,1);<br />
<br />
delete m_pgrid;<br />
<br />
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
First I appreciate your answer. But What I really want to know is, if it is a good idea to use a Grid that resides in a DLL. And if so How do I create an Object of it. I did this but with MFC and the autogenerated wrapper classes and everything works OK but I don`t know how to use it in a ATL/WTL project. This is because if I try to use the generated class I get some error about undefined class.
|
|
|
|
|
How do I set my combos height wich resides in a DialogBox
|
|
|
|
|
First make a call GetDlgItem with the handle of the parent dialog and the ID of your combo box. This will return a handle to the combo box to you.
You can then use that handle in a call to MoveWindow to resize and move the combo box.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
The problem is when I click on the combos down arrow, it won`t display the list. The list does contains some items. But I can`t see them.
|
|
|
|
|
Bring up your dialog in the resource editor. Click on the dropdown and pull the sizing box downward to the size you want.
|
|
|
|
|
Thakn you for your answer.
Seems like everything it`s dificult not knowing how to do it
|
|
|
|
|
Is there some article that demonstrates the use of one STL container inside another?
for example, how to use
std::map<std::string, std::vector<std::string> > x;
ie, how do i insert?
how do i get back the reference of the vector instead of copying it out?
etc.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
maybe multimap is a better fit for what you want here?
but, here is a code snippette that may be worth while though:
...
// define types
//
using namespace std;
typedef vector<string> STRING_LIST;
typedef map< string, STRING_LIST* > MAP_STRING_TO_LIST;
typedef MAP_STRING_TO_LIST::iterator MAP_STRING_TO_LIST_ITER;
// declare variable of type
//
MAP_STRING_TO_LIST oMyList;
bool InsertString( string oKey, string oValue )
{
MAP_STRING_TO_LIST_ITER oIter = oMyList.find( oKey );
if ( oMyList.end() == oIter )
{
// no entry yet for this key...
//
STRING_LIST* poList = new STRING_LIST;
poList->push_back( oValue );
oMyList.insert( MAP_STRING_TO_LIST::value_type( oKey, poList );
}
else
{
STRING_LIST* poList = (*oIter).second;
poList->push_back( oValue );
}
}
hope that helps
Just trying to keep the forces of entropy at bay
|
|
|
|
|
I can't recieve WM_CREATE message in my control . How could this happen? What are the possible reasons?
|
|
|
|
|
You might need to set the following variable in your constuctor
CComControlBase::m_bWindowOnly = TRUE;
Todd Smith
|
|
|
|
|
If it's dialogbased control, you should receieve WM_INITDIALOG instead.
--
Please state the nature of your medical emergency.
|
|
|
|
|
I've come across an interesting problem, that I can't find a nice clean solution to.
The problem is how to manage adding and deleting objects from two vectors containing different objects.
Here's what I've got: A list of objects that contain an vector of ints as data points. The object holding the list has an vector of description objects containing information about each of the ints in the vector. They have a one to one relationship.
Now, I need to support adding or removing data points. What I can't figure out how to do is how to do this without a lot of overhead. My first thought was that I'd simply get the position of the data point description object that was added, then simply do a for_each over the list and call insert or erase for the appropriate position in the data points vector as required by the operation. Unfortunately both of those functions require an iterator to the item being erased, or the position the new item is being inserted at, not just it's index position.
Is there a way to do this without iterating over each data point vector? Since the position in the vector is going to be the same for all the objects, it seems like there should be a way to do this without all the manipulation.
Any ideas?
|
|
|
|
|
Mark Tutt wrote:
Here's what I've got: A list of objects that contain an vector of ints as data points. The object holding the list has an vector of description objects containing information about each of the ints in the vector. They have a one to one relationship.
Why didn't you make a map in this case ? a map of <DataPoints,DescriptObj> ????? or if Description objects must be a vector of points ...
<DataPoints,vector<DescriptObj>> ?
So you want to remove a specific data point , it's enough to reference the data point .
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
|
|
|
|
|
If I'm understanding your question, it was to avoid the memory overhead of needing the have the description objects for each of the data point vectors.
A map would involve copies of the objects, greatly increasing memory requirements. There may be 10's or 100's of thousands of data point vectors, and I only need one set of description objects. Even having a pointer to the associated description object for each data point essentially doubles the memory requirements.
Mark
|
|
|
|
|
And why not use instead vector of pointers to Data Points ?
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
|
|
|
|
|
I think you're missing the point of what I was trying to do...
Think of rows in a database table. All you need is the data, stored in rows, in a sequential list that you can move through. (leaving out indexing for now)
The column information, i.e. Name, data type, default value, nullable, etc. is going to be the same for every row in the table. You don't need to carry the weight of that data along with each row, so you just have one copy of this for the table.
Now assume you've got a doubly linked list containing vectors (rows) of 10 integers each. You've got another vector that contains the column information for the 10 columns.
If you want to delete the 8th column, you've got to delete the 8th int from each row in the list.
If you were to add pointers to the integers, you're not really changing the basic requirement of the operation, and you're adding additional memory overhead of a 32byte pointer to a 32byte int, i.e. doubling the memory requirement.
What someone else pointed out was that given that we know the position in our column information vector, we can use datapoint.begin()+pos to get the datapoint iterator to the datapoint position that we have to erase, so we can do something like this to perform a 'column delete' operation on our entire dataset.
for_each(datalist.begin(), datalist.end, erase(data.begin()+pos))
|
|
|
|
|
You can have constant-time access to the n-th element of a vector v via the iterator v.begin()+n . I agree with you that proably std::vector is the best choice for holding huge arrays of int s. As for the description list, you'd probably be better off using a std::map<int,CDescription> . Access is log-time given the position, and insertions and deletions are way cheaper.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|