|
I have a dialog box that I am trying to change the background color of the listbox and text fields (CEDIT). This is what I have done so far:
1. In the header, public section,declare a variable (CBrush m_bkColor;)
2. Using wizard, created the WM_CTLCOLOR function
3. funtion looks like this
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_LISTBOX:
case CTLCOLOR_EDIT:
{
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkColor(RGB(192,220,192));
return (HBRUSH)(m_bkColor.GetSafeHandle());
}
case CTLCOLOR_BTN:
case CTLCOLOR_STATIC: //text for dialog box
//case CTLCOLOR_DLG: //dialog background color
//return static_cast<hbrush>(m_pBrush->GetSafeHandle());
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
The problem is that only the background of the text is colored, not the entire listbox or text fields.
Any help will be greatly appreciated.
|
|
|
|
|
I was using the wrong function.
I used m_bkColor.CreateSolidBrush(RGB(10,45,12));
fixed it.
thanX
|
|
|
|
|
When I debug my program, I do not get any errors. When I run the program, it wont quit. It is a dialog application and the button to exit is:
void COpenGLDialogDlg::OnOk()
{
CDialog::OnOK();
}
When I look at the task manager to quit the application, no application that is running shows up and the usage is at 100%.
Help!
Thanks,
Chris
|
|
|
|
|
have you tried replacing CDialog:OnOK() with simply OnOK() or PostQuitMessage(0)?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks for the suggestion. It turns out that it was my bad, a infinite loop...thanks again.
Regards,
Chris
|
|
|
|
|
Hello,
Need to save a user.
Here is the problem. I have a listbox with logs and a have a funktion that needs to check user and save it in to a file.
In the listbox there can be lots of text but I now what text to find, I when I find that user I need to check if the user in logon or if the user have logout. So I search for the user text and get the user and check how many logon and how many logout but I don't get it to work.
*** Listbox log ***
bla bla bla USER:test logon
bla bla text
bla bla text
bla bla user: test logout
bla bla bla user: test logon
First I search for the logon text and if I find that
I get the user namne.
And when I have the user name I check how many logon and how many logout, But there can be many users so I donn't now how I should get this to work!
So I need help please.
|
|
|
|
|
Hi!
I'm currently writing some help file for my application using HtmlHelp.
Now I have a problem: I have 2 folders, containing help documents, the first folder is always open (i.e. the documents are shown), but the second one is always closed. I want that the second folder is open, too...
How can I do that?
Thanks and best regards,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I have put a command button on a dialog form and I am trying to simply call AfxMessageBox("Simple message box."); when I do call this function, the dialog form dims as if it is giving up focus but does not show the message box and hangs. Is there a header file that I need to include to use this function? Is there a message map involved?
Please help!
Thanks,
Chris
|
|
|
|
|
There is nothing you need to call AfxMessageBox(). Sounds like something else is wrong. Replace the AfxMessageBox() call with a TRACE statement and see what happens. Also step through the code in the Debugger which should shed some light on what's going on.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
I do not get any errors when I do not have the AfxMessageBox() call. Any other suggestions?
|
|
|
|
|
Programmer_Chris wrote:
I do not get any errors when I do not have the AfxMessageBox() call. Any other suggestions?
Yes, stepping through in the debugger, like I already suggested.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Try to call MessageBox("Simple...") instead
|
|
|
|
|
I did and got the same problem. Thanks for the reply. Any other ideas?
|
|
|
|
|
Hello, I'm pretty new to programming, and while I can figure out in my head what I want the function to do, the syntax is a bit tricky. I want to create a template for a search function that looks for an ID in one of three containers. The three containers are pointers to either standard employees, security employees, or support employees.
If I were to create each search individually, I'd do it like this(nevermind crappy names etc)
prototype for employee:
int searchForIDNum(Employee* [], const int empCount, const string idToFind);
and when I make the call:
int employeeIndex = searchForIDNum(employeeContainer, empCount, idToFind);
How would I convert this to a template that I could use for all three classes? In particular, I'm having a tough time with the first parameter - the employeeContainer in both the prototype and the call. Any help is appreciated MUCH!!! Thanks!
|
|
|
|
|
Hello,
<br />
template <class T><br />
int searchForIDNum(T *pContainer, const int empcount, const string idToFind)<br />
{<br />
}<br />
Would do the trick, but may I ask why it is to hard to do a search on google for template?
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
My suggestion is that you don't even try to write a templated search function like this, the standard library provides the std::find_if template for this situation - not to mention providing a more generalised interface for modifying the search criteria.
For example, a very simple employee search might look something like this:
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Employee {
Employee(string n, int i) : name(n), id(i) { }
int id;
string name;
};
struct EmpName
{
EmpName(string toFind) : searchName(toFind) { }
bool operator()(Employee& e) {
if(e.name == searchName) {
return true;
}
return false;
}
string searchName;
};
int main()
{
vector<Employee> employees;
employees.push_back( Employee("bob", 0) );
employees.push_back( Employee("john",1) );
employees.push_back( Employee("mary",2) );
employees.push_back( Employee("fred",3) );
vector<Employee>::iterator searchResult;
searchResult = std::find_if(employees.begin(),employees.end(),EmpName("john"));
if(searchResult != employees.end())
{
cout << (*searchResult).id << endl;
}
else
{
cout << "not found" << endl;
}
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Hey Andrew, you beat me to it!
Kevin
|
|
|
|
|
I assume that the three types of employee are in an inheritance hierarchy? In any case the best way to deal with these kinds of problem is to use the STL algorithms. Though, if you are new to programming, I appreciate there is a learning-curve here.
This is what I would do for a simple Employee class.
class Employee
{
public:
Employee(int id, const string& name) : _id(id), _name(name) {}
int id() const { return _id; }
string name() const { return _name; }
private:
int _id;
string _name;
};
// Function Object
class EmployeeEqualTo
{
public:
EmployeeEqualTo(int id) : _id(id) {}
// Criterion for equality
bool operator()(const Employee& employee) const
{ return employee.id() == _id; }
private:
int _id;
};
int _tmain(int argc, _TCHAR* argv[])
{
Employee e1 = Employee(1, "Peter");
Employee e2 = Employee(2, "Paul");
Employee e3 = Employee(3, "Helen");
vector<Employee> employees;
vector<Employee>::const_iterator it;
employees.push_back(e1);
employees.push_back(e2);
employees.push_back(e3);
// Find Employee with id = 2
it = find_if(employees.begin(), employees.end(), EmployeeEqualTo(2));
cout << "Name: " << it->name() << ", id: " << it->id() << "\n";
return 0;
}
If each Employee type uses the same id function, which I assume should be the case, the above should work as is, otherwise you can generalise this for the different employees and replace the <Employee> with <Employee*> to preserve polymorphism and take care to deallocate the Employee*.
If all this looks a bit mysterious, try reading the various STL tutorials on this site.
Oh, and you'll need to include a few headers
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
Kevin
|
|
|
|
|
Hi Everybody,
I want to use my .swf files(macromedia flash)
in my mfc app.
please help me,
best wishes,
thanks.
|
|
|
|
|
1. Go to this site: http://www.macromedia.com/software/flash/[^].
2. Buy the product.
3. Read the manual.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Hi
Anyone used the ASTL library before in Visual C++? I am trying to use the ASTL library but am getting compile errors:
Compiling...
astl.cpp
c:\astl\astl.beta.2.0\include\dfa_matrix.h(108) : error C2955: 'char_traits' : use of class template requires template argument list
c:\program files\microsoft visual studio\vc98\include\iosfwd(135) : see declaration of 'char_traits'
c:\code\astltry\astl.cpp(7) : see reference to class template instantiation 'DFA_matrix<class range<char,65,90="">,struct empty_tag>' being compiled
c:\astl\astl.beta.2.0\include\dfa_matrix.h(129) : fatal error C1903: unable to recover from previous error(s); stopping compilation
c:\code\astltry\astl.cpp(7) : see reference to class template instantiation 'DFA_matrix<class range<char,65,90="">,struct empty_tag>' being compiled
Error executing cl.exe.
astltry.exe - 2 error(s), 0 warning(s)
Please help.
Thanks a lot.
|
|
|
|
|
Hi
I am beginner learning C++ and using the Visual C++ compiler. How do I add class templates so that I can use it in Visual C++? Please highlight the steps.
Thanks a lot.
|
|
|
|
|
Hello,
The steps for success are the following:
1) Do a Google search
2) Apply the results
3) If errors are the result, search some more. (More Google, MSDN, CP,...)
4) When your head feels like exploding, ask here on CP
Until you tried steps 1 through 3, you should try doing your homework yourself...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
I get compile errors when using iostream.h and fstream.h includes
while using .Net Pro 2003, but not VC++6.0 nor .Net Architect 2003.
How do I resolve this?
S. Thompson
|
|
|
|
|
try just typing #include < iostream > //without the *.h Thats working for me
humpa humpa
|
|
|
|
|