|
NS17 wrote: maximum popup time
I think that there isn't any limit
Russell
|
|
|
|
|
From my experiments I understood that it cant be set more than 0x7fff (signed short int max)
- NS -
|
|
|
|
|
|
TTM_SETDELAYTIME with TTDT_AUTOPOP flag
- NS -
|
|
|
|
|
Oh yes, got it.
Exactly, I found 7FFF milliseconds too.
If you need more I think that you need a custom tolltip that use a timer.
Russell
|
|
|
|
|
Less the code, lesser the bugs...
- NS -
|
|
|
|
|
|
You send the ToolTip control a TTM_SETDELAYTIME message with a WPARAM argument of TTDT_AUTOPOP and an LPARAM argument of the number of milliseconds
|
|
|
|
|
I have a button with text and an icon drawn on it.
If the user changes some entry, I want to be able
to change the text and the icon. I can do this, however,
everything just jumbles on top of the button. How can
I erase the background of the button so that when I
put the new text and icon, it looks clean?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: How can
I erase the background of the button so that when I
put the new text and icon, it looks clean?
How are you changing the icon and the text?
How are the icon and text drawn?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It looks like this:
<br />
void ColorYes(CXPStyleButtonST *m_button)<br />
{<br />
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
<br />
m_button->SetFont(SimpleFont);<br />
<br />
m_button->SetBitmaps(IDB_GREEN_CHECK, WHITE, IDB_GREEN_CHECK, WHITE);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
<br />
m_button->SetWindowText("Yes");<br />
}<br />
<br />
void ColorNo(CXPStyleButtonST *m_button)<br />
{<br />
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
<br />
m_button->SetFont(SimpleFont);<br />
m_button->SetBitmaps(IDB_RED_NO, WHITE, IDB_RED_NO, WHITE);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
<br />
m_button->SetWindowText("No");<br />
<br />
}<br />
I call ColorYes and it puts the bitmap and text on the button. I call
ColorNo and it puts the new bitmap and text on top of the button with
the old image and button.
I need to call something that clears the button before I add new
stuff. I just dont know what function to call.
??
|
|
|
|
|
I'm not familiar with the CXPStyleButtonST class.
Maybe someone familiar with it will read here, but you may want to
post the question to the author on the article page[^] too.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Since I don't know the code, I'm not sure if this will work...
I would pull common code out of these functions and just do them once
during initialization (when the button is created:
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
m_button->SetFont(SimpleFont);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
Then maybe try forcing a redraw:
void ColorYes(CXPStyleButtonST *m_button)<br />
{<br />
m_button->SetBitmaps(IDB_GREEN_CHECK, WHITE, IDB_GREEN_CHECK, WHITE);<br />
m_button->SetWindowText("Yes");<br />
<br /> m_button->Invalidate();
m_button->UpdateWindow();
}<br />
<br />
void ColorNo(CXPStyleButtonST *m_button)<br />
{<br />
m_button->SetBitmaps(IDB_RED_NO, WHITE, IDB_RED_NO, WHITE);<br />
m_button->SetWindowText("No");<br />
<br /> m_button->Invalidate();
m_button->UpdateWindow();
}<br />
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm not familiar with the CXPStyleButtonST class either, but the call to DrawTransparent() to redraw the button immediately raises my suspicions that it may not be erasing the background.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
with reference to the previous post clickety[^]
Cedric helped me in getting the function pointer definition correct as such:
typedef bool (WorkerClass::*pf)(std::string &, std::string &);
for Method signature:
bool fncSame( std::string &x , std::string &y );
I now have two questions.
1) Why does the following fail?
<br />
std::string a("a");<br />
WorkerClass::pf pfn = &WorkerClass::fncSame;<br />
pfn(&a,&a);<br />
giving me the error: "error C2064: term does not evaluate to a function taking 2 arguments"
2) Where would I use function pointers? (other than academically as I'm currently doing)
Many Thanks
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
is fncSame a static member function ? (it should be. if you're going to use it with fn pointers)
Mustafa Ismail Mustafa wrote: Where would I use function pointers?
you use them all the time when interacting with C-style interfaces (ex. qsort, EnumChildWindows, EnumFonts, WndProcs, etc). you find them often in C-interfaced libraries, where library authors add hooks to let you override library functionality without having to change any of the library's source code - just set the "errorOutput" function pointer (or whatever) to your own function instead of the built-in function.
C++ reduces their importance, though. since a lot of what they were used for in C is handled by the ability to override functions in base classes, you don't need to use function pointers - just derive from the base class and override a virtual function.
|
|
|
|
|
Chris Losinger wrote: is fncSame a static member function ?
Its not. I thought that both static and instance members could be used, but not interchangeably.
Anyways, I changed the method to static and now it gives me this error:
error C2440: 'initializing' : cannot convert from 'bool (__cdecl *)(std::string &,std::string &)' to 'WorkerClass::pf'
In addition to the previous error:
error C2064: term does not evaluate to a function taking 2 arguments
I'm using VS2005 if that means anything in this case.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
Chris Losinger wrote: is fncSame a static member function ? (it should be. if you're going to use it with fn pointers)
The pointer type is as follows (I added the underline):
typedef bool (WorkerClass::*pf)(std::string &, std::string &)
The function must be a non-static member function of WorkerClass .
Steve
|
|
|
|
|
Mustafa Ismail Mustafa wrote: I now have two questions.
1) Why does the following fail?
std::string a("a");
WorkerClass::pf pfn = &WorkerClass::fncSame;
pfn(&a,&a);
Because it doesn’t make sense: what instance of the class would the member function be called on? You need something like this:
WorkerClass wc;
std::string a("a");
WorkerClass::pf pfn = &WorkerClass::fncSame;
(wc.*pfn)(&a,&a a, a);
-- modified at 3:39 Wednesday 3rd October, 2007
Steve
|
|
|
|
|
Another you have to take care of (Stephen already answered the main question):
bool fncSame( std::string &x , std::string &y );
This is your function signature: it requires two string parameters that are passed by reference. When you use it, you do that:
pfn(&a,&a);
Which is wrong, because you pass the addresses of the strings (pointers). You should do this instead (and take in account the answer of Stephen of course ):
pfn(a,a);
|
|
|
|
|
Oops. Ta for that correction.
Steve
|
|
|
|
|
So I'm trying to sort each value from a files. A user inputs a string of 8 numerals. then breaks the string down to an array and writes each element from the array to a file on each line.
So if the user inputs: 87654321
Its output in the file will be:
8
7
6
5
4
3
2
1
What I want to do is get the first integer of the file, compare it to the second and write to a new file the numbers in ascending order:
1
2
3
4
5
6
7
8
Now, I am aware of the sort() func, and would like to avoid it as much as possible. I'm trying to use the if/for/while to accomplish this task. Below is my code of what I have so far:
<code>
// fstsreamCompare.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int v;
int loop;
int aA[8];
string ns;
int _tmain(int argc, _TCHAR* argv[])
{
ofstream ouI;
ouI.open("rwB.dat");
if( ouI.fail()){
cout << "Error reading file: " << endl;
exit(1);}
ifstream inI;
inI.open("rwB.dat");
if( inI.fail()){
cout << "Error writing file: " << endl;
exit(1);}
do {
cout << "File(SORT) Input an 8-Digit numeral: "; cin >> ns;
if ( ns.length() < 8 )
{
cout << "Human Error! " << "The value is too short!" << endl;
cout << "The value: " << ns << " is " << ns.length() << " digits long." << endl;
cout << "Press any key to re-enter a valid numeral." << endl;
_getch();
system("CLS");}
else if ( ns.length() == 8)
{
aA[0] = ns[0] - '0';
aA[1] = ns[1] - '0';
aA[2] = ns[2] - '0';
aA[3] = ns[3] - '0';
aA[4] = ns[4] - '0';
aA[5] = ns[5] - '0';
aA[6] = ns[6] - '0';
aA[7] = ns[7] - '0';
for ( v=0; v<ns.length(); v++ )
ouI << aA[v] << endl;
}
} while ( ns.length() < 8 ); system("CLS");
cout << endl << "Values have been written to FILE(SORT)" << endl;
cout << "Press any key to sort the values." << endl << endl;
_getch();
return 0;
}
</code>
And thanks to David Crow I know how to convert strings to arrays .
I know how to get the first integer from the file but don't know how to get the second to begin comparing.
Keep in mind this is not a school project this is for my leisure.
|
|
|
|
|
I'd do something like this -- but I'd use the std::sort function!
-----------------------------------------------------------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <stdexcept>
using namespace std;
inline int CharToNum(char ch)
{
// Check for a bad digit.
if (ch<'0' || ch>'9')
{
throw range_error("Non-digit encountered!");
}
return ch-'0';
}
void main()
{
// Get a string of numbers from the user.
string s;
cout << "Enter a string of chars: ";
cin >> s;
// Create an array of numbers from the string -- each digit is one entry.
vector<int> nums;
try
{
transform(s.begin(), s.end(), back_inserter(nums), CharToNum);
}
catch (const range_error &e)
{
cout << e.what() << endl;
return;
}
// Sort the numbers.
sort(nums.begin(), nums.end());
// Output the results.
copy(nums.begin(), nums.end(), ostream_iterator<int>(cout, "\n"));
}
Steve
|
|
|
|
|
hi
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int v;
int loop;
int aA[8];
string ns;
int _tmain(int argc, _TCHAR* argv[])
{
ofstream ouI;
ouI.open("rwB.dat");
if( ouI.fail()){
cout << "Error reading file: " << endl;
exit(1);}
do {
cout << "File(SORT) Input an 8-Digit numeral: "; cin >> ns;
if ( ns.length() < 8 )
{
cout << "Human Error! " << "The value is too short!" << endl;
cout << "The value: " << ns << " is " << ns.length() << " digits long." << endl;
cout << "Press any key to re-enter a valid numeral." << endl;
_getch();
system("CLS");}
else if ( ns.length() == 8)
{
aA[0] = ns[0] - '0';
aA[1] = ns[1] - '0';
aA[2] = ns[2] - '0';
aA[3] = ns[3] - '0';
aA[4] = ns[4] - '0';
aA[5] = ns[5] - '0';
aA[6] = ns[6] - '0';
aA[7] = ns[7] - '0';
for ( v=0; v<ns.length(); v++="" )
="" oui="" <<="" aa[v]="" endl;=""
="" }
="" }="" while="" (="" ns.length()="" <="" 8="" );="" system("cls");
="" oui.close();="" cout="" endl="" "values="" have="" been="" written="" to="" file(sort)"="" endl;
="" "press="" any="" key="" sort="" the="" values."="" ifstream="" ini;
="" ini.open("rwb.dat");
="" if(="" ini.fail()){
="" "error="" writing="" file:="" "="" exit(1);}
="" char="" buff;
="" int="" aarray[8];
="" for(="" iloop="0" ;="" iloop<8;iloop++)
="" {
="" ini.getline(&buff,2,'\n');
="" aarray[iloop]="buff-'0';
" ini.close();
="" <b=""> print unsorted data but from the file
for( int iLoop=0 ; iLoop<8;iLoop++)
{
cout<
|
|
|
|
|
Herboren wrote: And thanks to David Crow I know how to convert strings to arrays .
Although it was not C++.
It looks as though all you need to do is sort the numbers in ascending order before the for (v=0; ...) loop writes them to the file. That is, unless you actually want the original numbers in a file beforehand.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|