|
"an error has occurred in your application.if you choose ignore,you should save your work in a new file.if you choose close ,your application will terminate."please provide solution for this error.
kir_MFC
|
|
|
|
|
Please give more information on this? just by giving an error like this we will not be able to help you.
|
|
|
|
|
iam doing my project using vc++ 1.52.the objective this project is providing GUI to one devise called quick panel.in this project when i execute Qmgr.exe it is showing the fallowing error."an error has occurred in your application.if you choose ignore,you should save your work in a new file.if you choose close ,your application will terminate."
kir_MFC
|
|
|
|
|
kir_MFC wrote: ...when i execute Qmgr.exe...
Using what?
kir_MFC wrote: ...it is showing the fallowing error."an error has occurred in your application.if you choose ignore,you should save your work in a new file.if you choose close ,your application will terminate."
Have you searched?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I'm using Visual C++ and Windows XP
I would like to continuously increment a counter when the left mouse button is down, and then display the number of counts. The basic logic I'm trying to implement is:
count = 0;
while (left_mouse_button_down) count++;
It isn't clear to me how to do something like this in the Windows environment. Any insights would be greatly appreciated.
Thanks David!
|
|
|
|
|
If you need this feature only within your application window, it's simply a matter of adding a handler for the mouse click event (WM_LBUTTONDOWN ).
If you need this on a global scale (with no regards to which application window has the focus), you need to install a mouse hook. The following resources will get you started:
SetWindowsHook() API[^]
Hooks and DLLs[^] (has a sample mouse hook implementation with source)
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You didn't say anything about the counter "sensitivity". If you implemented something more or less similar as what you did, your counter would reach an extremely high value in a few miliseconds. What would be the point ? Furthermore it would totally depends on the speed of the computer on which your program is running. Do you need to increase your counter every second ?
Once you defined your sensitivity, you can simply create a timer that fires at your sensitivity rate. You start your timer when the button is pressed and you kill the timer (and display your counter if needed) when the mouse button is released. When the timer fires, you simply increase your counter.
EDIT: by looking at the answer of Rajesh, I'm not sure I understood your question properly. Do you want to count the number of times the user clicks the mouse or do you want to increase your counter while the mouse button is down ? I understood the second one.
|
|
|
|
|
Cedric Moonen wrote: or do you want to increase your counter while the mouse button is down ?
And if that's the case, do you want it to work with all applications or not? And... And if...
These guys keep us puzzled with the lack of information in their posts.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: These guys keep us puzzled with the lack of information in their posts.
Stop your whining. That was all spelled out in your contract.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yeah, if you want to be an MVP the least you can do is try and guess what the question might be
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
You got me there.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
To clarify things a bit. I am actually trying to use a laptop PC to compare whether the on time of an external signal varies under different conditions. We have an external setup that will turn a switch on and then off. We want to test if this external signal's on time varies very much under different condtions. We are trying to find out whether that switch is on for the same length of time each time we turn it on or not. We are looking for time resolutions in the micro-second range, or tens of micro-second range. We are trying to decide whether we can do a quick test with a PC or whether we need to build an electronic counting circuit (we could buy an electronic counter but we are trying to keep the price low for our initial testing). We are thinking about having our external device simply use the mouse input. The problem is the system time resolution. The idea with the PC is to shut off all programs except windows and our timing program. We were thinking if we simply incremented a count as fast as possible, we could detect small changes in our external signal by repeating the test and comparing the different counts during the on time. If we could detect the small changes in time (microseconds or tens of microseconds), then we would plan to repeat things with more costly test equipment. But for now we are just trying to see if there is any way we can do some programming to detect small changes in the external signal's on time.
|
|
|
|
|
Windows is no good at all at the usec or 10usec level. And the mouse logic is designed to follow a human's manipulation, which is a few Hz at most. You will need some DIY electronics or a somewhat sophisticated frequency meter.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Rajesh has replied to you how to count the number of times the left button is pressed.
If you want to increase a timer every (eg, 0.1s) but only if the button is down (ehich is how I read your post), then you need to do two things:
1: Set a timer, and handle it. See SetTimer , OnTimer / WM_TIMER for more information.
2: When you're in the timer routine, check if the button is pressed down.
It took a bit of hunting, but you can call GetASyncKeyState with a parameter of VK_LBUTTON to find out whether the button is pressed or not.
I hope one of these interpretations matches up with your needs.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
The GetASyncKeyState sounds exactly what I'm looking for. My plan is to do a timing test to see how long it takes for each cycle of a loop that checks the mouse key and increments a count. Once I've done that calibration for the PC I'm using, I can then simply use that function to start and stop the counter to give me the time I'm lloking for.
Thanks!
Dave
|
|
|
|
|
Hi all,
i receive this error please help me how can i solve this.
my stdafx.h looks like this.
#if !defined(AFX_STDAFX_H__1EAE1E61_6C55_4340_B919_9DA4E2BE11F0__INCLUDED_)
#define AFX_STDAFX_H__1EAE1E61_6C55_4340_B919_9DA4E2BE11F0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <atlbase.h>
#include <atlstr.h>
#include <atlapp.h>
extern CAppModule _Module;
#include <shellapi.h>
#include <atlwin.h>
#include <atlframe.h>
#include <atlctrls.h>
#include <atlctrlx.h>
#include <atldlgs.h>
#include <atlcrack.h>
#include <atlcoll.h>
#include <atlddx.h>
#import ".\MSO.DLL" \
rename( "RGB", "MSORGB" )
using namespace Office;
#import ".\VBE6EXT.OLB"
using namespace VBIDE;
#import ".\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" )
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h>
please help for this
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
One might wonder why you're using WTL AND MFC...but anyway.
You need to put the MFC includes in before the ATL includes - MFC doesn't like Windows.h being included before it is (and ATL does that).
You may also need to add the line
#define _CSTRING_NS
so that WTL can see CString properly.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Sorry - is your app mainly MFC or mainly WTL?
It doesn't really matter, anyway - the code for reading Excel posted in that article is independent of WTL or MFC. WTL is only used to display the results of reading the Excel file - you could re-implement that in MFC very simply.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
its mainly MFC.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
As I said, the Excel reading code is independent of WTL or MFC. The important line is this one:
#import ".\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" )
That imports the Excel type library into your C++ program, using smart pointers and managed variants and BSTRs.
Look for the string Excel:: in MainDlg.cpp from that article - that shows you the bits of code that are interfacing with Excel.
For example:
Start Excel
Excel::_ApplicationPtr pApplication;
if ( FAILED( pApplication.CreateInstance( _T("Excel.Application") ) ) )
{
Errorf( _T("Failed to initialize Excel::_Application!") );
return;
}
Load an Excel workbook
_variant_t varOption( (long) DISP_E_PARAMNOTFOUND, VT_ERROR );
Excel::_WorkbookPtr pBook = pApplication->Workbooks->Open( dlgFile.m_szFileName, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption );
Get the first worksheet
Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[ 1 ];
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
My 5 for your tolerance.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
In MFC the above can be done by using CListCtrl class.
but how to do the same in win32 ?
Please help.
|
|
|
|
|
There is no easy way. There is no "check" style for a listbox - there's an MFC class which does clever things for you.
Have a look at the code for CCheckListBox, and you'll see it actually does owner draw for the listbox. I can't remember how it stores the check state - either as item data, or an internal map.
So, you'll have to learn how to do owner draw in Win32 (just a case of setting the right styles and responding to a couple of messages) and implement the functionality yourself.
If I were you, I'd grab large sections of the work from CCheckListBox - but you'll still have quite a bit of effort to do.
Good luck!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Thanks for the reply Iain.
I think we can use ListControl in place of listbox.
When I am using ListControl on the dialog, the dialog is not becoming visible.
Does anyone have some idea about it ? Can I use ListControl in a win32 application to show the checkbox.
Thanks in advance
|
|
|
|