|
hmmmm but then i dont seem to understand why the MFC version DOES work. the only difference in the MFC version is that i use AfxGetInstanceHandle(); to get the HINSTANCE used in SetWindowsHookEx...
Any explanation?
(thanks for the advice about the DLL, i kind of already knew but wanted to try and put it all in one exe anyways)
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
hmmmm but then i dont seem to understand why the MFC version DOES work
Was it inside an MFC DLL or an MFC EXE? If the latter, then I don't seem to understand either.
Any explanation?
None that I can think of without further investigation. I'd try peeping at AfxGetInstanceHandle source code to see what's making a difference.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You have to put the callback for the keyboard hook in a DLL to make it possible to log when a user is pressing a key when your app is not in focus.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Hi ,
I'm trying to send error message from my ATL object (Visual C++ 6.0, MFC) to Visual Basic 6.0 application.
I tried using:
1. AfxThrowOleDispatchException(0x200, "Some Exception", 0);
2. COleDispatchException* pException;
pException = new COleDispatchException(
_T("Some Exception"), 200, 425);
pException->m_scError = 0;
THROW(pException);
But the message box I get in VB is that of Abnormal Program Termination, Abort, Retry, Ignore?
Could anyb'dy throw some light on this matter?
Thanks,
|
|
|
|
|
I think you can trap OLE (as well as other) exceptions with the VB construct On Error GoTo . If you're new to this technique, maybe you'll want to have a look at Mark Hurst's VB Error Handling: Frequently Asked Questions.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your instant response.
If I return return E_FAIL; then I'm able to trap it in VB Error handling, but then the message I get is "Method <methodName> of object <objectName> failed".
I'm unable to raise my application/ATL-Object defined error codes and descriptions.
Any clue?
|
|
|
|
|
|
Thanks Again!
The article mentions "This behavior is by design in Visual Basic version 3.0. Visual Basic for Applications ..." but what I'm using is VB 6.0 which is not supposed to have any bug.
Besides the code is identical to the one that I posted.
I'm sure I'm missing something important.
|
|
|
|
|
Anyb'dy's been successful in raising custom error messages/automation from ATL/COM (6.0) to VB (6.0)?
Please Help!!
|
|
|
|
|
HI Guys,
i am using the CStdioFile ReadString() Function to read several files with the size of 350KB per File. Sometimes it takes to long to load the files and sometimes my app crashes. Is there any solution to save loading time ??? maybe any other function ?
Best Regards
Sonu
|
|
|
|
|
...and sometimes my app crashes. Is there any solution to save loading time ???
Your app crashing is a very likely sign that you've got a bug in your code --this may have to do with the poor performance you're obtaining, also.
Could you post the piece of code in which you're using ReadString ? This would help determine what's going on.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
My app only crashes cause the files which i am loading are to large. If i
try this with smaller files, everything works fine. So i need a solution for
the loading Problem.
strFile is just a csv file with the size of 350KB.
CString sRow;
CStdioFile inFile(strFileName, CFile::modeRead);
while(inFile.ReadString(sRow) != FALSE)
{
// loading the String in a ListCtrl
}
inFile.Close();
you see i am not doing very much
Best Regards
Sonu
|
|
|
|
|
what about checking if "inFile" is valid?
could be a problem as well
modified 12-Sep-18 21:01pm.
|
|
|
|
|
350 kb is surely not large enough to cause a crash. It must be something in your code. Carefully go through it step by step.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I know. I tryed the same with smaller files and everything works fine. NO CRASH
Best Regards
Sonu
|
|
|
|
|
I don't think CStdioFile is having anything to do with the slowness of your code (you can verify this commenting out the code inside the loop and seeing if the app still goes slow).
More probably it is the process of populating the CListCtrl that is causing your app to go slowmo. You can do two things to accelerate this process:- Rick York pointed out an interesting idea in a previous thread today that applies to your case. Use
WM_SETREDRAW to prevent redrawing while you fill the list:
list.SendMessage(WM_SETREDRAW,(WPARAM)FALSE,0);
while(...){
...
}
list.SendMessage(WM_SETREDRAW,(WPARAM)TRUE,0);
- Make sure the styles
LVS_SORTASCENDING and LVS_SORTDESCENDING are note set for the list control, to prevent sorting in the middle of the population process. Later, you can sort the data (if this is your wish) with CListCtl::SortItems .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx I will try this. Maybe this can solve my Prob.
Best Regards
Sonu
|
|
|
|
|
I'm trying to learn using "Sams Teach Yourself Visual C++ 6 in 21 Days". Has anybody read that? I'm finding that there are a lot of mistakes in the sample code in the book. For example, I took this code exactly out of the book:
void CDialogsDlg::OnYesnocancel()
{
// TODO: Add your control notification handler code here
int iResults;
iResults = MessageBox("Press the Yes, No, or Cancel button", "Yes, No, Cancel Dialog",
MB_YESNOCANCEL | MB_ICONINFORMATION);
switch(iResults)
{
case IDYES:
m_sResults = "Yes! Yes! Yes!";
break;
case IDNO:
m_sResults = "No, no, no, no, no.";
break;
case IDCANCEL:
m_sResults = "Sorry, canceled.";
break;
}
UpdateData(FALSE);
}
and I got these errors:
--------------------Configuration: Dialogs - Win32 Debug--------------------
Compiling...
DialogsDlg.cpp
C:\Windows\Desktop\Dialogs\DialogsDlg.cpp(185) : error C2065: 'm_sResults' : undeclared identifier
C:\Windows\Desktop\Dialogs\DialogsDlg.cpp(185) : error C2440: '=' : cannot convert from 'char [15]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Windows\Desktop\Dialogs\DialogsDlg.cpp(188) : error C2440: '=' : cannot convert from 'char [20]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Windows\Desktop\Dialogs\DialogsDlg.cpp(191) : error C2440: '=' : cannot convert from 'char [17]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
DialogsDlg.obj - 4 error(s), 0 warning(s)
Am I forgetting to do something, because I've doubled checked the code and its exactly what appears in the book. This is happening to me for every single code in the book. Can anybody recommend a better book?
|
|
|
|
|
It looks to me like m_sResults is a member variable, probably a CString mapped in classwizard to an edit box or a static control or something.
What does that mean? well, you can add an edit box to your dialog in the dialog editor. You've probably already learned that in VC/MFC, a dialog is represented by a class. well, each control on the dialog box is represented by a member variable in that class. you use the class wizard tool to control the mappings between controls on the dialog, and memebr variables in your class.
The code snippet you've typed in relies on this class wizard mapping being setup: if it was, you wouldnt be getting those errors.
I think therefore that the code you are reading is meant to be indicative of the point in discussion and not directly intended to be typed in and tried. It probably isn't necessary for the book to explain how to make every classwizard mapping for every control in every example.
If there's a CD in the book, it probably has VC projects to open of all these code snippets, so you can see the code in action. These projects will include all of the dependant configuration that is omitted from the sample.
Stick at it, and if you get stuck, post here... people will help.
You'll feel very rewarded when you write your first working MFC app on your own. But I warn you now, the 21 days thing is a gimmick... it takes years to learn VC++ properly. The really knowledgeable people on this forum have all been using VC for years, and I bet if you asked any of them they'd tell you they're still learning.
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
just forgot to say thank you
|
|
|
|
|
Please stop including your whole project every time you have a problem.
And spending some more time describing what the problem is would help too
:\Windows\Desktop\DataStru\main.cpp(639) : error C2664: 'binarySearch' : cannot convert parameter 1 from 'class Stock *(void)' to 'class Stock *' There is no context in which this conversion is possibleError executing cl.exe.main.obj - 1 error(s), 0 warning(s)
on line 639, cast your parameter 1 to (Stock *).
|
|
|
|
|
You missed a ; - or did you. Use MSDN, and then you would leard the following :
'function' : cannot convert parameter number from 'type1' to 'type2'
The following is an example of this error:
class A {} a;
func( int, A );
void main()
{
func( 1, 1 );
}
It just gets on my tits. Do some investigation and try an narrow the problem down by say - commenting out code!!!!!! And seeing if it still recompiles, unless you wrote all of this with out one build.
Don't let me see you post a stupid question with all this code again.
Giles
|
|
|
|
|
I'll just add my voice to the people saying you should take a closer look yourself before posting, and at the least show you've done that by only posting the offending code instead of half your project, and describe your problem a bit.
However,
return -(first +1); //failed to find
why are you returning a range of numbers to indicate failure ? Usual practice is to return -1. what if a client of this function accidentally sends a range that starts at -3 ? You're not doing any range validation ( i.e. checking for valid values to be passed in ), which makes all of this code very fragile.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
I have an embedded Visual C++ program, which uses the Imgdecmp.dll to load and display JPEG images.
Zooming is achieved through a variable contained in the Decompress Image Structure (an int between 1 and 100). This works fine, however the map needs to be reloaded (via the open file dialog everytime the user zooms in or out)to show the zoom effect.
Does anyone know a way around this...any suggestions greatly appreciated.
Cheers,
Colm
|
|
|
|
|
Hello,
I am not able to include any class derived from CListView or CTreeView in my project for say a child view of some sort.
I get error saying the class is undefined.
I can however make a new project with either of the views by selecting the right choice in the app wizard.
Why?
|
|
|
|