|
Are you creating the dialog in a separate thread ? In which case that would explain why you are still able to interract with the parent window.
|
|
|
|
|
I have an CComboBoxExt derived from CCOmboBox .. but I have an small problem , perhaps you can help me :
CComboBoxExt m_Combo;
void CTestComboView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
m_Combo.AddString("One");
m_Combo.AddString("Two");
m_Combo.AddString("Three");
}
and when I type 'O' in combobox , it select me automatically 'One' item from the list ... well , I try this one :
void CComboBoxExt::OnEditupdate()
{
CString sText;
GetWindowText(sText);
DWORD dwCurSel = GetEditSel();
WORD dStart = LOWORD(dwCurSel);
WORD dEnd = HIWORD(dwCurSel);
if(dStart == 0 && dEnd == sText.GetLength())
SetEditSel(sText.GetLength(),sText.GetLength());
}
but have no effect ....
|
|
|
|
|
I forget to say something :
I use this , may me this cause weird behaviour ?
void CComboBoxExt::OnEditchange()
{
CString sText;
GetWindowText(sText);
if(sText.IsEmpty())ShowDropDown(FALSE);
else ShowDropDown();
}
|
|
|
|
|
mesajflaviu wrote: ...but I have an small problem...
Which is?
You've shown code, but have failed to explain what is supposed to happen vs. what is actually happening.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
The problem is that when I type 'O' , the control autocompletion 'One' in editbox , select all text and put the mouse cursor at the end of the 'One' string .. is annoynig , because I want to type myself all string ... for more details , I put here[^] an source code .. .just type 'O' in combobox ....
|
|
|
|
|
Hello friend, I think a lot of people in this board have ever been used "Print to file" option in Printer Dialog.
That it can save our printing job to file and then print it out later.
I want to create a program that can read that file.
And the program also can revise the printer setting and page set up before the real printing.
Please advise me some concept or article of this task.
Thank you
|
|
|
|
|
I assume you are talking about the .xps file.
There is a COM API provided by Microsoft for working with this file format. See the documentation on MSDN[^]
Grab the latest version of the Windows SDK[^], which you will need to comiple your project, but also has some great little samples under the folder C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\xps (alternativley you can download just the samples from http://code.msdn.microsoft.com/xps[^]). The documentation for these samples can be found on MSDN[^].
|
|
|
|
|
hello, anyone have an idea of a code in MFC to shut down with time the pc ? in Vs 2008 ?
|
|
|
|
|
|
the function ExitWindowsEx[^] can be used to shut down the computer.
To do it after a specific period you could use something like Sleep(1000); (wait 1 second) or a WM_TIMER event in a GUI application.
To do it at a specific time you need to figure out how long to wait. Use either GetSystemTime[^] or GetSystemTimeAsFileTime[^] to get the current time, then calculate how long you need to wait. After that you can used 1 of the previously mentioned ways of delaying.
|
|
|
|
|
I an't figure it out how to make a provision for multiple authors...
Here is my code....
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string null = "";
//class(1) Book Title
class bkTitle
{
string ATitle;
public:
//construtor
bkTitle();
bkTitle(string);
//Mutator member functions
void setTitle(string Title) {ATitle = Title;}
//accessor funtions
string getTitle() {return ATitle;}
string toString();
};
//Default construtor
bkTitle::bkTitle()
{
ATitle = null;
}
bkTitle::bkTitle(string Title)
{
ATitle = Title;
}
string bkTitle::toString()
{
string Form;
Form = ATitle;
return Form;
}
//Class(2)First define a class to represent names...
class shortName {
string firstName;
string lastName;
public:
//Declare the constructors...
shortName();
shortName(string, string);
//Define the mutator member functions...
void setFirst(string First) { firstName = First;}
void setLast(string Last) { lastName = Last;}
//...and some accessor functions
string getFirst() { return firstName;}
string getLast() { return lastName;}
string toString();
};
//Define the default constructor...
shortName::shortName()
{
firstName = null;
lastName = null;
}
//...and the initializing one...
shortName::shortName(string First, string Last)
{
firstName = First;
lastName = Last;
}
string shortName::toString()
{
string Form;
Form = firstName + " " + lastName;
return Form;
}
//class(3) Publisher Name
class PbName
{
string PbN;
public:
//constructor
PbName();
PbName(string);
//mutator member funtions
void setPb(string Pb) {PbN = Pb;}
//acessor funtions
string getPb() { return PbN;}
string toString();
};
//default constructor
PbName::PbName()
{
PbN = null;
}
//initializing one
PbName::PbName(string Pb)
{
PbN = Pb;
}
string PbName::toString()
{
string Form;
Form = PbN;
return Form;
}
//Class(4)publisher address
class shortAddress {
string StreetID;
string StreetName;
string CityName;
string StateName;
string ZipCode;
public:
//Declare the constructors...
shortAddress();
shortAddress(string, string, string, string, string);
//Define the mutators...
void setID(string ID) { StreetID = ID; }
void setStreet(string Street) {StreetName = Street; }
void setCity(string City) { CityName = City; }
void setState(string State) { StateName = State; }
void setZip(string Zip) { ZipCode = Zip; }
//...and the accesors...
string getID() { return StreetID; }
string getStreet() { return StreetName; }
string getCity() { return CityName; }
string getState() { return StateName; }
string getZip() { return ZipCode; }
string toString();
};
//Define the default constructor...
shortAddress::shortAddress()
{
StreetID = null;
StreetName = null;
CityName = null;
StateName = null;
ZipCode = null;
}
//Define the initializing constructor...
shortAddress::shortAddress(string ID, string Street, string City, string State, string Zip)
{
StreetID = ID;
StreetName = Street;
CityName = City;
StateName = State;
ZipCode = Zip;
}
string shortAddress::toString()
{
string Form;
Form = StreetID + " " + StreetName + "\n" + CityName + ", " + StateName +
" " + ZipCode;
return Form;
}
//Publisher(Phone Number)
class shortPhone {
string AreaCode;
string Prefix;
string Number;
public:
//Declare the constructors...
shortPhone();
shortPhone(string, string, string);
//Define the mutators...
void setArea(string Area) { AreaCode = Area; }
void setPrefix(string Pref) { Prefix = Pref; }
void setNumber(string Num) { Number = Num; }
//...and the accesors...
string getArea() { return AreaCode; }
string getPrefix() { return Prefix; }
string getNumber() { return Number; }
string toString();
};
//Define the default constructor...
shortPhone::shortPhone()
{
AreaCode = null;
Prefix = null;
Number = null;
}
//Define the initializing one...
shortPhone::shortPhone(string Area, string Pre, string Num)
{
AreaCode = Area;
Prefix = Pre;
Number = Num;
}
string shortPhone::toString()
{
string Form;
Form = "(" + AreaCode +") " + Prefix + "-" + Number;
return Form;
}
//class(5) Catagory
class bkCategory
{
string bkCa;
public:
//constructor
bkCategory();
bkCategory(string);
//mutator member funtions
void setCa(string Ca) {bkCa = Ca;}
//acessor funtions
string getCa() { return bkCa;}
string toString();
};
//default constructor
bkCategory::bkCategory()
{
bkCa = null;
}
//initializing one
bkCategory::bkCategory(string Ca)
{
bkCa = Ca;
}
string bkCategory::toString()
{
string Form;
Form = bkCa;
return Form;
}
//class(6) Date of Publication
class DateofPublication
{
string TDop;
public:
//constructor
DateofPublication();
DateofPublication(string);
//mutator member funtions
void setDop(string Dop) {TDop = Dop;}
//acessor funtions
string getDop() { return TDop;}
string toString();
};
//default constructor
DateofPublication::DateofPublication()
{
TDop = null;
}
//initializing one
DateofPublication::DateofPublication(string Dop)
{
TDop = Dop;
}
string DateofPublication::toString()
{
string Form;
Form = TDop;
return Form;
}
// Class(7) For The Information Of Books In The Library
class BookRecord
{
bkTitle Titlebk;
shortName AuthorName;
PbName PublisherName;
shortAddress PublisherAddress;
shortPhone PublisherPhone;
bkCategory Category;
DateofPublication bkDop;
public:
// Define Constructors
BookRecord();
BookRecord (bkTitle, shortName, PbName, shortAddress, shortPhone, bkCategory, DateofPublication);
// Define Mutators
BookRecord(string, string, string, string, string, string, string,
string, string, string, string, string, string, string);
//Define some mutators...
//Title
void setTitle(string Title) { Titlebk.setTitle(Title); }
//Author Name
void setFirst(string First) { AuthorName.setFirst(First); }
void setLast(string Last) { AuthorName.setLast(Last); }
//Publisher Name
void setPb(string Pb) { PublisherName.setPb(Pb); }
//Publisher Address
void setID(string ID) { PublisherAddress.setID(ID); }
void setStreet(string Street) { PublisherAddress.setStreet(Street); }
void setCity(string City) { PublisherAddress.setCity(City); }
void setState(string State) { PublisherAddress.setState(State); }
void setZip(string Zip) { PublisherAddress.setZip(Zip); }
//Publisher Phone Number
void setArea(string Area) { PublisherPhone.setArea(Area); }
void setPrefix(string Prefix) { PublisherPhone.setPrefix(Prefix); }
void setNumber(string Number) { PublisherPhone.setNumber(Number); }
//Book Category
void setCa(string Ca) { Category.setCa(Ca); }
//Date of Publication
void setDop(string Dop) { bkDop.setDop(Dop); }
//Define appropriate accessors...
//Title
string getTitle() { return Titlebk.getTitle(); }
//Author Name
string getFirst() { return AuthorName.getFirst(); }
string getLast() { return AuthorName.getLast(); }
//Publisher Name
string getPb() { return PublisherName.getPb(); }
//Publisher address...
string getID() { return PublisherAddress.getID(); }
string getStreet() { return PublisherAddress.getStreet(); }
string getCity() { return PublisherAddress.getCity(); }
string getState() { return PublisherAddress.getState(); }
string getZip() { return PublisherAddress.getZip(); }
//Publisher Phone
string getArea() { return PublisherPhone.getArea(); }
string getPrefix() { return PublisherPhone.getPrefix(); }
string getNumber() { return PublisherPhone.getNumber(); }
//Category
string getCa() { return Category.getCa(); }
//Date of Publiation
string getDop() { return bkDop.getDop(); }
// conversion Function
string toString();
};
BookRecord::BookRecord()
{
; //This is a command...that doesn't do anything....
}
//We can use an initializing constructor for the times when
// we have the values before we create the object...
//Initializing Constructor
BookRecord::BookRecord(bkTitle ClientTitle,shortName ClientName,PbName ClientPublisherName,
shortAddress ClientPublisherAddress,shortPhone ClientPublisherPhone,bkCategory ClientCategory,DateofPublication ClientbkDop)
{
Titlebk = ClientTitle;
AuthorName = ClientName;
PublisherName = ClientPublisherName;
PublisherAddress = ClientPublisherAddress;
PublisherPhone = ClientPublisherPhone;
Category = ClientCategory;
bkDop = ClientbkDop;
}
//This alternative initializing constructor can be
// used in different context...
BookRecord::BookRecord(string Title, string First, string Last, string Pb, string ID, string Street,
string City, string State, string Zip, string Area,
string Prefix, string Number, string Ca, string Dop)
{
Titlebk.setTitle(Title);
AuthorName.setFirst(First); //We have to use the mutators because the
AuthorName.setLast(Last); //components are locked away in classes...
PublisherName.setPb(Pb);
PublisherAddress.setID(ID);
PublisherAddress.setStreet(Street);
PublisherAddress.setCity(City);
PublisherAddress.setState(State);
PublisherAddress.setZip(Zip);
PublisherPhone.setArea(Area);
PublisherPhone.setPrefix(Prefix);
PublisherPhone.setNumber(Number);
Category.setCa(Ca);
bkDop.setDop(Dop);
}
// Output The Information Of Books
string BookRecord::toString()
{
string Form;
Form= "\n==============================\nTitle: " +
Titlebk.toString() + "\nAuthor: " +
AuthorName.toString() + "\nPublisher Name: " +
PublisherName.toString() + "\nPublisher address:" +
PublisherAddress.toString() + "\nPublisher Phone Number and Contact Name:" +
PublisherPhone.toString() + "\nCategory: " +
Category.toString() + "\nDate of Publication: " +
bkDop.toString() + "\n" +
"==============================\n";
return Form;
}
//The next task is to package the list processing functions in a class...
const BookRecord NullRecord; //We'll need this object later...
// class(8) For books In The Library
class BookRecordList
{ vector<BookRecord> List; //We need to create a collection object...
public:
BookRecordList() {;} //Right now the default constructor doesn't do much...
void AddBookRecord(BookRecord);
BookRecord FindBookRecord(string);
BookRecord SearchBookRecord(string);
bool RemoveBookRecord(string);
string DisplayAllBookRecords();
};
//The add function is probably the easiest to implement...all the work was
// done in the other definitions...
void BookRecordList::AddBookRecord(BookRecord NewBookRecord)// Add book
{
List.push_back(NewBookRecord);
}
BookRecord BookRecordList::FindBookRecord(string Last)// Search by Author Last Name
{
vector<BookRecord>::iterator FindList; //Define a smart pointer that will take us through the vector..
for(FindList = List.begin() ; FindList != List.end() ; FindList++)
if(FindList->getLast() == Last)
return *FindList; //If we have a match, send back the matching record...
return NullRecord; //We only get here when the entire list was traversed and there's no match.
}
BookRecord BookRecordList::SearchBookRecord(string Pb) // Search by A Title
{
vector<BookRecord>::iterator SearchList; //Define a smart pointer that will take us through the vector..
for(SearchList = List.begin() ; SearchList != List.end() ; SearchList++)
if(SearchList->getPb() == Pb)
return *SearchList;
return NullRecord;
}
bool BookRecordList::RemoveBookRecord(string Title)
{
vector<BookRecord>::iterator RemoveList;
for(RemoveList = List.begin() ; RemoveList != List.end() ; RemoveList++)
if(RemoveList->getLast() == Title) {
List.erase(RemoveList); //If we have a match, it's remove from the vector...
return true; //Let the calling function know it was successful...
}
return false; //The only way it gets here is that there was no match...the calling
//function needs to know that as well...
}
//The removal function is also traditionalist...we search for the correct one using the last name
//and then we remove it...
string BookRecordList::DisplayAllBookRecords()
{
vector<BookRecord>::iterator OutputList; //a smart pointer will take us through the vector...
string OutputForm;
for(OutputList = List.begin() ; OutputList != List.end() ; OutputList++) {
OutputForm += "======================================\n" + //Keep extending the string until you
OutputList->toString() +
"=======================================\n";
}
return OutputForm;
}
//Class(9)Create a BookList Interface Class
class BookRecordListUI {
BookRecordList Collection; //Create a object that contains a list...
public:
BookRecordListUI() {;} //Still not much for this to do...
void Menu();
void CommandProcessor();
void AddBookRecords();
void RemoveBookRecords();
void SearchbyAuthorLastName();
void SearchbyPublisherName();
void DisplayBookRecords();
};
void BookRecordListUI::CommandProcessor()
{
string Command;
while(true)
{
Menu();
cout << "Command: ";
getline(cin, Command);
if(Command == "Quit" || Command == "q")
break;
else if(Command == "Add Book" || Command == "1")
AddBookRecords();
else if(Command == "Remove a Book" || Command == "2")
RemoveBookRecords();
else if(Command == "Find By The Author Last Name" || Command == "3")
SearchbyAuthorLastName();
else if(Command == "Find By The Publisher Name" || Command == "4")
SearchbyPublisherName();
else if(Command == "Display" || Command == "5")
DisplayBookRecords();
}
}
void BookRecordListUI::Menu()
{
cout << "\nWelcome To Horace Library!" << endl;
cout << "\t1.Add A Book(puts a new book in the collection)" << endl;
cout << "\t2.Remove A Book(remove book from the collection)" << endl;
cout << "\t3.Searh By The Author Last Name(searches the collection for a book that matches the specified Author Last Name)" << endl;
cout << "\t4.Searh By The Publisher Name(searches the collection for a book that matches the specified Publisher Name)" << endl;
cout << "\t5.Display(shows the entire collection)" << endl;
}
void BookRecordListUI::AddBookRecords()
{
BookRecord LocalRecord;
string Title;
string First, Last;
string Pb;
string ID, Street,City, State,Zip;
string Area, Prefix, Number;
string Ca;
string Dop;
cout << "Enter Values Below, Type q To Quit" << endl;
while(true) {
cout << "Title: ";
getline(cin, Title);
if(Title == "q") break;
LocalRecord.setTitle(Title);
cout << "Enter Name..." << endl;
cout << "First: ";
getline(cin, First);
if(First == "q") break;
cout << "Last: ";
getline(cin, Last);
if(Last == "q") break;
LocalRecord.setFirst(First); //Set the name
LocalRecord.setLast(Last);
cout << "Publisher Name: ";
getline(cin, Pb);
if(Pb == "q") break;
LocalRecord.setPb(Pb);
cout << "Enter Address..." << endl;
cout << "Street Number: ";
getline(cin, ID);
if(ID == "q") break;
cout << "Street Name: ";
getline(cin, Street);
if(Street == "q") break;
cout << "City: ";
getline(cin, City);
if(City == "q") break;
cout << "State: ";
getline(cin, State);
if(State == "q") break;
cout << "Zip Code: ";
getline(cin, Zip);
if(Zip == "q") break;
LocalRecord.setID(ID); //...and the address...
LocalRecord.setStreet(Street);
LocalRecord.setCity(City);
LocalRecord.setState(State);
LocalRecord.setZip(Zip);
cout << "Enter Telephone Number..." << endl;
cout << "Area Code: ";
getline(cin, Area);
if(Area == "q") break;
cout << "Prefix: ";
getline(cin, Prefix);
if(Prefix == "q") break;
cout << "Number(please indicate the contact name after the number): ";
getline(cin, Number);
if(Number == "q") break;
LocalRecord.setArea(Area); //...and finally the telephone number...
LocalRecord.setPrefix(Prefix);
LocalRecord.setNumber(Number);
cout << "Book Category: ";
getline(cin, Ca);
if(Ca == "q") break;
LocalRecord.setCa(Ca);
cout << "Date of Publication: ";
getline(cin, Dop);
if(Dop == "q") break;
LocalRecord.setDop(Dop);
Collection.AddBookRecord(LocalRecord); //put it on the list...
}
}
//This function allows the user to look for names on the list...
void BookRecordListUI::SearchbyAuthorLastName()
{
BookRecord LocalRecord;
string Last;
cout << "Enter Author Last Name Below, Type q To Quit" << endl;
while(true) {
cout << "Author Last Name: ";
getline(cin, Last);
if(Last == "q") //Indicates the user is done...
break;
LocalRecord = Collection.FindBookRecord(Last); //Collect the results
if(LocalRecord.getLast() == null) //Didn't find it
cout << "Book Not Found" << endl;
else
cout << LocalRecord.toString(); //Otherwise, show the record...
}
}
void BookRecordListUI::SearchbyPublisherName()
{
BookRecord LocalRecord;
string Pb;
cout << "Enter Author Last Name Below, Type q To Quit" << endl;
while(true) {
cout << "Publisher Name: ";
getline(cin, Pb);
if(Pb == "q") //Indicates the user is done...
break;
LocalRecord = Collection.FindBookRecord(Pb); //Collect the results
if(LocalRecord.getPb() == null) //Didn't find it
cout << "Book Not Found" << endl;
else
cout << LocalRecord.toString(); //Otherwise, show the record...
}
}
void BookRecordListUI::RemoveBookRecords() // Function 3
{
BookRecord LocalRecord;
string Title;
cout << "Enter The Title Below, Type q To Quit" << endl;
while(true)
{
cout << "Title: ";
getline(cin, Title);
if(Title == "q")
break;
if(Collection.RemoveBookRecord(Title))
cout << Title << " Removed" << endl;
else
cout << Title << " Not Found!" << endl;
}
}
void BookRecordListUI::DisplayBookRecords()
{
cout << "=======================================================" << endl;
cout << Collection.DisplayAllBookRecords();
cout << "=======================================================" << endl;
}
//Notice how small the main() has shrunk...
int main()
{
BookRecordListUI Members; //Create a UI object...
Members.CommandProcessor(); //Set it in motion...
}
|
|
|
|
|
First and foremost, PLEASE remove most of the code and keep only the minimum necessary code.
I admit I did not read all of the code...
Maybe each book can have a std::vector of author ? after that is done, re-thing your class design and the UI design to that that into consideration.
for example (pseudo-codish):
typedef std::pair< std::string firstName, std::string lastName> Author;
class Book
{
std::vector<Author> m_Autors;
}
Watched code never compiles.
|
|
|
|
|
Please read How to ask a question with particular reference to point 7.
I must get a clever new signature for 2011.
|
|
|
|
|
Hello,
I am VC++/MFC developer. I wanted to start Bluetooth socket programming. Can you suggest any good book or article specific to Bluetooth programming.
Regards
|
|
|
|
|
|
Actually I went through all these pages..but I am not getting what I exactly want. I have completed my application using these pages, I myself not willing to use that.
I know I need to use Winsock2. But still something is not working properly.
Regards
|
|
|
|
|
Get a copy of the latest Windows SDK[^] and take a look at the bluetooth example in C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples\netds\winsock\bluetooth
|
|
|
|
|
OK. I will try and let you know. Thanks
|
|
|
|
|
You could check out the source of my Bluetooth remote control written in C++/MFC. It uses modified MFC CAsyncSocket to listen to Bluetooth connections.
|
|
|
|
|
Hello,
I am VC++/MFC developer. First of all I wanted to know is there any way in windows to block website. Suppose I wanted to block Facebook.com.
Secondly, I wanted to create one application that will block listed website. Suppose I have list of website with me viz; Google.com, orkut.com, Microsoft.com. I want to write application which can block these website.
Thanks in advance.
|
|
|
|
|
There are couple of things i can think off.
1. put sites url to a ini file for example then use API for working with inifiles (write / read profilestring)
2. get a list from ini file and resolve each site's ip
3. put then these ips into C:\Windows\System32\drivers\etc\hosts file and redirect to localhost for example
4. write a driver to disable write permissions on that file (you need to hook ntwritefile and some more)
5. that still will not block apps, which use custom resolver (anyways, most of apps use gethostbyname).
Or, maybe, detect network threads, then inject own thread into them and block access to a site on that level.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
csrss wrote: There are couple of things i can think off.
1. put sites url to a ini file for example then use API for working with inifiles (write / read profilestring)
2. get a list from ini file and resolve each site's ip
3. put then these ips into C:\Windows\System32\drivers\etc\hosts file and redirect to localhost for example
4. write a driver to disable write permissions on that file (you need to hook ntwritefile and some more)
5. that still will not block apps, which use custom resolver (anyways, most of apps use gethostbyname).
Or, maybe, detect network threads, then inject own thread into them and block access to a site on that level.
Hi,
I have added following line @ hosts file
66.220.146.11 www.facebook.com
but still facebook is running.
|
|
|
|
|
It should be:
127.0.0.1 www.facebook.com
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
The simple solution is having a program that modifies the hosts file, and gives the blocked domains an invalid IP address.
The normal solution in a corporate network is to setup a filter on the gateway to the Internet.
|
|
|
|
|
Rolf Kristensen wrote: The normal solution in a corporate network is to setup a filter on the gateway to the Internet.
Can you please give me steps how should I filter gateway?
|
|
|
|
|