|
Thankyou guys, I can now finally put my mind at rest! There was me thinking my new Pentium 4 machines were bunk, when all along it was those bloody vectors! Interesting note you made with regards to the difference between an array of 10 integers and a vector of 10 Todd, even I was suprised by the excessive routine it goes through, geeze. Well, I must say cheers to all you guys for coming up with the solution, at least we all know not to use vectors in a similar situation again, AND we know why.
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I've cross posted this into the C++ forum, cause a) it didn't get answered in the COM forum, b) the most knowledgeable people seem to hang out here. This problem was presented to me by a co-worker. It really has me stumped.
In our shop we utilize an application generator "Cool Plex". It builds C++ code and compiles it into dlls. One of its abilities is to include ActiveX controls on a screen. We have written an ActiveX control that dynamically creates a form using Combo box, ListBox and Ms MaskEdBox control. A typical usage might include 2 or 3 instances of each.
The Problem:
Inside our ActiveX we capture the Tab key in each control (control_OnKeyUp) and set focus to the next control, except for the MaskedEdit controls. We get other keys in the KeyUp event, but not the Tab key!!??
If I create a VB app and embed the control in it, the tabbing works as normal, So far, even worse. Now it appears the PLEX generated application is inhibiting the Tab key from getting to the MaskedEdit control which is encapsulated in our ActiveX control. Other encapsulated controls seem to work fine.
It seems to me that these symptoms are mutually exclusive. I don't see how this is possible, but the developer on this project has convinced me that this is what is happening.
1. PLEX container passes (or never gets) Tab key presses to the ActiveX control.
2. PLEX container inhibits the Tab key when the focus inside the ActiveX control is in a MaskedEdit control.
3. I believe the encapsulated control with the focus, gets the events before PLEX, precluding inhibiting the tab key at all.
4. PLEX container has no way to differentiate the encapsulated control with the focus from any other.
5. PLEX container has no way to differentiate the type of control. How could it know that the focus in our Activex control is on a MaskEdBox?
Thanks for the help,
Bill
Thanks for the help,
Bill
|
|
|
|
|
I'm making a dictionary application and I want to know how to map message, when users key-in their vocabulary in combobox and then press enter, with my "Search" procedure. I already mapped button message with my "Search" procedure. I don't know how to use WM_KEYDOWN or ON_WM_KEYDOWN.
Help me, please..
|
|
|
|
|
Hi!!!
Kindly suggest me a resource/web site from where I can get the sample documentation reports of Software projects. I just want to get the idea that how modern professional software documents are been written these days, and how various phases of SDLC are managed.
Sheeraz Khan
|
|
|
|
|
|
Hello, it's me again.
I did all your advises but still have nothing changes ...
If it's possible, can you, please look my code, where is mistake?
all best ..
-----------------------------
void CRegListDlg::QueryKey(HWND hDlg, HKEY hKey)
{
CHAR achKey[MAX_PATH];
CHAR achClass[MAX_PATH] = ""; // buffer for class name
DWORD cchClassName = MAX_PATH; // length of class string
DWORD cSubKeys; // number of subkeys
DWORD cbMaxSubKey; // longest subkey size
DWORD cchMaxClass; // longest class string
DWORD cValues; // number of values for key
DWORD cchMaxValue; // longest value name
DWORD cbMaxValueData; // longest value data
DWORD cbSecurityDescriptor; // size of security descriptor
FILETIME ftLastWriteTime; // last write time
DWORD i, j;
DWORD retCode, retValue;
CHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
CHAR achBuff[80];
// Get the class name and the value count.
RegQueryInfoKey(hKey, // key handle
achClass, // buffer for class name
&cchClassName, // length of class string
NULL, // reserved
&cSubKeys, // number of subkeys
&cbMaxSubKey, // longest subkey size
&cchMaxClass, // longest class string
&cValues, // number of values for this key
&cchMaxValue, // longest value name
&cbMaxValueData, // longest value data
&cbSecurityDescriptor, // security descriptor
&ftLastWriteTime); // last write time
// SetDlgItemText(hDlg, IDE_CLASS, achClass);
// SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE);
::SendMessage(GetDlgItem(hDlg, m_list),
LB_ADDSTRING, 0, (LONG) "..");
DWORD dwLength = MAX_PATH;
// Enumerate the child keys, until RegEnumKeyEx fails. Then
// get the name of each child key and copy it into the list box.
SetCursor(LoadCursor(NULL, IDC_WAIT));
for (i = 0, retCode = ERROR_SUCCESS;
retCode != ERROR_NO_MORE_ITEMS; i++)
{
retCode = RegEnumKeyEx(hKey,
i,
achKey,
&dwLength,
NULL,
NULL,
NULL,
&ftLastWriteTime);
if (retCode != (DWORD)ERROR_NO_MORE_ITEMS)
{
::SendMessage(GetDlgItem(hDlg, m_list),
LB_ADDSTRING, 0, (LONG) achKey);
}
dwLength = MAX_PATH;
}
SetCursor(LoadCursor (NULL, IDC_ARROW));
// Enumerate the key values.
SetCursor(LoadCursor(NULL, IDC_WAIT));
if (cValues)
{
for (j = 0, retValue = ERROR_SUCCESS;
j < cValues; j++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retValue = RegEnumValue(hKey, j, achValue,
&cchValue,
NULL,
NULL, // &dwType,
NULL, // &bData,
NULL); // &bcData
if (retValue != (DWORD) ERROR_SUCCESS &&
retValue != ERROR_INSUFFICIENT_BUFFER)
{
wsprintf (achBuff,
"Line:%d 0 based index = %d, retValue = %d, "
"ValueLen = %d",
__LINE__, j, retValue, cchValue);
// MessageBox (m_hWnd, achBuff, "Debug", MB_OK);
}
achBuff[0] = '\0';
// Add each value to a list box.
if (!lstrlen(achValue))
lstrcpy(achValue, "<no name="">");
wsprintf(achBuff, "%d) %s ", j, achValue);
::SendMessage(GetDlgItem(hDlg,m_list2),
LB_ADDSTRING, 0, (LONG) achBuff);
}
}
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
-------------------------------------------------
and it makes this mistake
: error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
each time when it goes to "SendMessage" ..
==============
www.design.kg
|
|
|
|
|
GetDlgItem doesn't take a handle to a window as its first parameter, it takes a control ID (ID_MY_BUTTON or something).
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Hello, the codegurus around the world;)
The poster simply misunderstands between CWnd function and Windows API function.
Windows API
HWND GetDlgItem(
HWND hDlg,
int nIDDlgItem
);
And, MFC
CWnd* GetDlgItem( int nID ) const;
void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;
Also, if the poster wants to use WinAPI function in MFC,
we need the global resultion ::GetDlgItem(...);
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Yah! And as you can see exactly like this I called this function:
::GetDlgItem
Or I did smf wrong?
==============
www.design.kg
|
|
|
|
|
I found it here:
http://msdn.microsoft.com/library/en-us/sysinfo/regapi_0tq1.asp?frame=true
is it MSDN mistake, that GetDlgItem take a handle to a window as its first parameter?
==============
www.design.kg
|
|
|
|
|
Hello, the codegurus around the world.;)
First of all, you must understand the dif between C and C++ code.
In msdn example, this is written by C code.
In this case, we don't need the global resolution "::".
VOID QueryKey(HWND hDlg, HANDLE hKey)
{
.....
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
}
However, if you use this one in MFC,
void CMyDialog::QueryKey(...)
{
.....
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
.....
SendMessage(::GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
......
or GetDlgItem(IDL_LISTBOX);
}
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Like this:
::SendMessage(::GetDlgItem(m_hWnd, m_list),
LB_ADDSTRING, 0, (LONG) "..");
The result is:
: error C2664: 'GetDlgItem' : cannot convert parameter 2 from 'class CString' to 'int'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
==============
www.design.kg
|
|
|
|
|
Hello, the codegurus around the world.;)
::SendMessage(::GetDlgItem(m_hWnd, m_list),
LB_ADDSTRING, 0, (LONG) "..");
How did you declare m_list? CString m_list?
GetDlgItem has the second parameter as ID of the control.
So, this should take something like IDC_LIST1.
But, are you sure that you add ListBox (ID: IDC_LIST1) on your dialog box?
Simply copying the code never works unless you have enough knowledge
of both MFC and Win32 program in this case.
Or, to be sure, you add ListBox on your dialog box.
This works.
If you declare CListBox m_list;
::SendMessage(m_list.m_hWnd, LB_ADDSTRING, 0, (LONG) "..");
or
m_list.AddString ("..");
or
m_list.SendMessage(LB_ADDSTRING, 0, (LONG)"..");
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Oh, ÎÃÐÎÌÍÎÅ ÑÏÀÑÈÁÎ!
thats in my language mean THANK YOU VERY MUCH! Masaaki
==============
www.design.kg
|
|
|
|
|
"::GetDlgItem(m_hWnd, m_list)" <--- error line
The second parameter should be the control id.
replace m_list with the control id,something like IDLIST01
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
|
|
Hello,
In the following code, I open a MP3 and read the last 128 bytes of information (to see if the MP3 has a ID3 tag).. This code works fine most of the time.. I click the open button on my app which calls this function.. it works 95% of the time, but every now and then it gives me an error.. "an unnamed file was not found", the file does exist and its in the same directory as all the previous files that I have opened.. if I move or copy the file to another location and try to open it, it opens fine.. weird! Any ideas why??
CFileDialog MP3(TRUE,NULL,NULL,OFN_HIDEREADONLY,"MP3 Files (*.mp3)|*.mp3|");
if(MP3.DoModal() == IDOK)
{
strPath = MP3.GetPathName();
ID3TAG.Open(strPath, CFile::modeRead);
ID3TAG.Seek(-128,CFile::end);
ID3TAG.Read(tagData,128);
Thanks,
Rob
|
|
|
|
|
perhaps the file is open by some other process or thread already?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
It shouldn't be open by any other processes. It's on my local machine, I don't have any other apps that are using the file and I don't have any shares open on my PC. I wonder if the strPath string is getting corrupted some how.. I'll do some traces.
If you have any other ideas please let me know.
Thanks!!
Rob
|
|
|
|
|
It appears that the CFile::Seek function is throwing the error.. Any ideas why? It's like it can't find the end of the file. Is there any trouble shooting methods that I can use to determine the cause of the exception?
Thanks again for you help!
Rob
|
|
|
|
|
I don't usually reply to my own msg's but I figured everything out.. so disregard my last few posts..
Thanks,
Rob
|
|
|
|
|
Are you sure, that the file is opened properly ???
For a better error description you might use SDK functions CreateFile, ReadFile, CloseHandle and GetLastError instead of mfc.
And perhaps a work-around:
Get the file length, move to byte position (FileLength-128) from start, read the last lines ... But to be honest, I don`t believe that it is the Seek which really causes the trouble here...
Regards, Marco
|
|
|
|
|
Hy everyone,
I'm tryng to do an application that show in some window the current amount of memory in the user's hard disc. But when the user is using win 95 before OSR2 the function GetDiskFreeSpaceEx must be replaced by GetDiskFreeSpace, and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... I do everything they tell me to do... but in win 95 my program do not work...
causes an error on kernel32.dll that can't find de GetDiskFreeSpaceExA... please, if someone can help me it's will be great!
I'll post an part of my code that I do the implementation of the MSDN Library:
P_GDFSE pGetDiskFreeSpaceEx = NULL;
pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"),"GetDiskFreeSpaceExA");
if(pGetDiskFreeSpaceEx)
{
fresult = GetDiskFreeSpaceEx (windowsDir,
(PULARGE_INTEGER)&FreeBytesToCaller,
(PULARGE_INTEGER)&TotalBytes,
(PULARGE_INTEGER)&FreeBytes);
m_strDirSistema = _T( windowsDir );
m_dwQuotaLivreUsuario = /*(DWORD*/FreeBytesToCaller / MEGABYTE; // this lines given
- me warnings of conversion but it's work correctly m_dwEspacoTotal = /*(DWORD)*/TotalBytes / MEGABYTE;
m_dwEspacoLivre = /*(DWORD)*/FreeBytes /MEGABYTE;
}
thanks all, for the attention!
cheers!!
and sorry my english, I'm brazilian
|
|
|
|
|
You say that "MSDN Library tell's" [you to] "dynamically link to it via GetProcAddress"
But in your code, you're trying to dynamically link to GetDiskFreeSpaceExA, not GetDiskFreeSpace.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|