|
When I refresh a Edit Control’s text every 1.5second, the Edit Control flashes occasionally. Anybody can tell me why and how to avoid it.
In same application, my other Edit Control do the same things, but won’t flash.
|
|
|
|
|
Hi all,
This is not a problem I'm seeing with my own applications, but this can definitely be labeled a programming question...
Right now I have two applications running on my machine that are consuming over 2000 handles each: Outlook 2003, and RSS Bandit.
SysInternal's Process Explorer shows that both of these have hundreds of handles to HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap being held.
Searching Google for "leak" and "internet settings\zonemap" comes up with a few hits, one of them from some guy claiming that a simple C app that brings up a dialog box with IE and then destroys it is leaking two handles to that same key. That post is dated February of this year, and it had no reply.
I'm running XP Pro with all the latest updates.
Anyone else? Thoughts, comments?
|
|
|
|
|
I'm trying to search an input file for all occurences of a user specified string and return how many times the word was found and read that into an output file. For some reason the the value of the string changes to every word in the text file at runtime. What am I doing wrong?
#include <iostream><br />
#include <string><br />
#include <ciso646><br />
#include <fstream><br />
using namespace std;<br />
<br />
int main(void)<br />
{<br />
<br />
<br />
string filename;<br />
cout << "Please enter the name of the file: " ;<br />
cin >> filename;<br />
string search;<br />
cout << "Please enter the word to search for";<br />
cin >> search;<br />
<br />
ifstream fin(filename.c_str());<br />
while (fin.fail())<br />
{<br />
cout << "invalid file name"<< endl;<br />
cout << endl << "Please enter the name of the file: ";<br />
cin >> filename;<br />
<br />
fin.clear();<br />
fin.open( filename.c_str() );<br />
<br />
}<br />
<br />
int count=0;<br />
<br />
while (fin >> (search))<br />
{<br />
<br />
count++;<br />
<br />
}<br />
<br />
ofstream fout("output.txt");<br />
fout << "The number of times "<< search <<" was found is "<< count << endl;<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
system ("pause");<br />
return 0;<br />
}
BINARY
|
|
|
|
|
Binary,
Your problem exists here:
while (fin >> (search))
{
count++;
}
You are reading a "word" from your file and storing it in the string that you declared to hold your search term. Instead, reuse the filename variable or declare a new one.
while (fin >> (filename))
{
count++;
}
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
-- modified at 16:04 Wednesday 23rd November, 2005
|
|
|
|
|
Hi!.
I'm trying to build an existing VC++ 6.0 activex project for Pocket PC with Visual Studio 2005.
With the "Configuration manager" I have added the plataform "Pocket PC 2003 (ARMV4)", that's what I want for now.
But the compiler throw the following error:
"Error 1 fatal error C1189: #error : Must define a target architecture. c:\Archivos de programa\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\include\winnt.h 648 "
So, it looks that in some place I should define the target architecture, (ie: _WIN32, but for WINCE), but where?, and what is the #define???
Thank you.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi,
Where to put my Registration or Login Screen Dialog in a Document/View SDI (MFC) application ? I tried to the InitInstance but i get Assert errors.
I suppose there are two ways to show this dialog, 1)Before the application starts 2) Just after the Application start
Regards,
George
sdancer
|
|
|
|
|
I usually do this, after the application has started. If you don't want to show the main dialog, hide it after InitInstancd and before showing the registration one ...
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Hi,
In Initinstance
m_pMainWnd->LaunchLoginScreen();
In mainfrm.cpp
LaunchLoginScreen()
{
LoginDlg = new LoginDlg();
LoginDlg->DoModal();
delete LoginDlg;
LoginDlg=NULL;
}
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Hi,
Is there any way in MFC to have global variables ? I need this, for example to have access to a database connection string, from anywhere in the program not only in the Document/View but in the Dialogs too.
Regards,
sdancer
|
|
|
|
|
I've used 2 different approaches:
1. Define a static class called CGlobal and define it with static variables and functions.
2. Make it a member of your Application class and use theApp.m_connectionstring
My articles
BlackDice
|
|
|
|
|
I tend to put them in stdafx.cpp, and extern them in stdafx.h.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
sdancer75 wrote: Is there any way in MFC to have global variables ? I need this, for example to have access to a database connection string, from anywhere in the program not only in the Document/View but in the Dialogs too.
I believe in making Singleton class and use it object in while application!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
my app send 1 byte (value='11111111') to LPT1. In one PC (Win2K-PRO) I see value:'11111111' but in other PC I see value:'00111111', pin D7,D6 always is '0'.
Why ? How to set LPT ?
|
|
|
|
|
To input using the data byte (pins 2-9), the port should be configured as bi-directional; i.e, can input and output on the same pins. There is a bit in I believe (forgot the address, either 0x379, or 0x37A), which needs to be set to input data from the port, instead of the usual output.
If you have already made it bi-directional, then there is something wrong with the wiring, or the port, or it is something else.
this is this.
|
|
|
|
|
Outport(0x378,ch) that is ok, but Inport(0x378) always give last value, that was Outport before.
- How to read data in ?
|
|
|
|
|
Hi all,
I am looking for an advice how to write data into exactly location in a file name in MFC VC++ 2003. I have sections as [DDS] and [DC offset].
I know how to iplement it in builder c++ 6, but I failed in MFC VC++ 2003 (it is hard to me). Where I can get info. Thanks.
Editbox1 contains 10 which is written in to section [DDS] with ID (Start Freq)
ex: myfile.ini contains
[DDS]
Start Freq : 10 ;Mhz comment
Stop Freq : 25 ;Mhz
Step : 1 ;Khz
[DC offset]
I : 220
Q : 245
MilkyWay
|
|
|
|
|
Loc Milkyway wrote: I am looking for an advice how to write data into exactly location in a file name in MFC VC++ 2003. I have sections as [DDS] and [DC offset].
What about this class :-
http://www.codeproject.com/cpp/CIni.asp#xx660934xx[^]
Anyways
Loc Milkyway wrote: [DC offset]
I : 220
Q : 245
Ini generally contain = (Equal to Sign) to seperate key and value instead of : (Colon)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thank you for advice. The class and demo are good. But I don't know how to use GetInt(...). I made a simple GUI with 1 button and i edit box, when button is clicked, the key value should be displayed on edit box. But default value is displayed. Something is wrong I could not figure out.
Here is my
ini file contains
[SECTION1]
Key1 = String
Key2 = 14
[SECTION2]
Key1 = 20.5
Key2 = a
simple GUI contains
void CsimpleINIfileTestDlg::OnBnClickedButton4()//open file
{
CString Str; //ok here
Str = "3"; //ok here
m_ebSECT1KEY2.SetWindowText(Str); //ok here - 3 is displayed on edit box
CFileDialogEx dlg(TRUE, _T("ini"), NULL, /*OFN_HIDEREADONLY | */ OFN_OVERWRITEPROMPT,
_T("Ini Files (*.ini)|*.ini|All Files (*.*)|*.*||"),
this);
if (dlg.DoModal() == IDOK)
char m_sSectionX[]= "SECTION1";
char m_sKEYX[] = "KEY2";
Str.Format(_T("%d \n"), m_ini.GetInt(m_sSectionX , m_sKEYX, 7, BASE_DECIMAL));
m_ebSECT1KEY2.SetWindowText(Str);
/* always get value 7 - result as 4 above lines
CString m_sSection = _T("SECTION1"); //m_sSection will be destroyed by next line CString m_sKEY = _T("KEY2");
CString m_sKEY = _T("KEY2");
Str.Format(_T("%d \n"), m_ini.GetInt(_T("SECTION1"), _T("KEY2"), 7, BASE_DECIMAL));
m_ebSECT1KEY2.SetWindowText(Str);
*/
}
MilkyWay
|
|
|
|
|
Loc Milkyway wrote: CFileDialogEx dlg(TRUE, _T("ini"), NULL, /*OFN_HIDEREADONLY | */ OFN_OVERWRITEPROMPT,
_T("Ini Files (*.ini)|*.ini|All Files (*.*)|*.*||"),
this);
if (dlg.DoModal() == IDOK)
Problem Lies here, you forget to set path of selected Ini file.
m_ini.SetPathName(dlg.GetPathName());
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Good advice my dear.
MilkyWay
|
|
|
|
|
Hi all,
Do you know how to simulate a left button mouse click on another application ? (use SendMessage api ?)
Thanks,
ken
|
|
|
|
|
You will need the HWND of the window to which you want to send the mouse-click. Actually it is the WM_LBUTTONDOWN and WM_LBUTTONUP messages which need to be sent.
You can:
::SendMessage(hWnd,WM_LBUTTONDOWN,0,MAKELPARAM( x, y ));<br />
::SendMessage(hWnd,WM_LBUTTONUP,0,MAKELPARAM( x, y ));
It seems that the toolbars, menus, caption bars etc do not respond to this technique, however I am not sure.
this is this.
|
|
|
|
|
kendao wrote: Do you know how to simulate a left button mouse click on another application ? (use SendMessage api ?)
Better Use mouse_event Function or SendInput function for Simulating mouse on your or other window
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hi, How a window exract text from another window(eg: MSWord,Excel..).Is there any API to exract text. Or there is any other way to exract. If any one has answer please help me.
For eg: Capturing tools like SnagIt captures from different window. I want to know how do these capturing tools like SnagIt do it.
Jewel Nandy,
Mumbai,India
|
|
|
|
|
Try FindWindowEx() to find the main window, then use it again passing the main window as the parent, and it will go through the child windows one at a time. Maybe that'll be a start. I think the first time you have to pass a null as the parent window's handle and just specify the window caption.
My articles
BlackDice
|
|
|
|
|