|
use EnumDisplayMonitors[^];
I think the callback gets you a dc
to the particular portion of the
virtual desktop for each monitor.
|
|
|
|
|
hi, this old question... I need to retrieve the names of all columns given a table in form of an array of "char*"
I wrote. But this is syntatically incorrect of course:
pRs->Fields->GetItem( _variant_t(i))->get_Name(bstrFieldName);
tried to search for samples, all in VB:
For Each objField In objRecordset.Fields
' convert BSTR field name into char* field name....
Next
Havent been able to find one VC yet. Perhaps u can speed me up. THanks!
norm
|
|
|
|
|
If you know the column number of the column name you're looking for, just do this:
short colIndex = 5;
CODBCFieldInfo info;
pRs->GetODBCFieldInfo(colIndex, info);
If you need to iterate through the fields, just get a column count with GetODBCFieldCount() on the recordset and loop through calling GetODBCFieldInfo each time.
Hope this helps.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
thanks but i was explicitly told that this job be done via ADO...
anyway, but one more question:
how can u check if a field is a PK or FK? ADO recordset Field properties?
Code fragment would be appreciated.
THnaks
norm
|
|
|
|
|
You may consider using Carlos Antollini ADO classes from here[^]
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
...
i'm almost done with my module... just need this one last line to determine whether a field is a PK or FK...
To get field name:
pRs->Fields->Item[j]->get_Name(&bstrFieldName);
//Convert BSTR to char*
if(pszFieldName==NULL)
{
//Additional error handling here.
}
WideCharToMultiByte(CP_ACP, 0, bstrFieldName, -1, pszFieldName, this->m_nMaxFieldName+1, NULL, NULL);
To get Field Type:
_itoa(pRs->Fields->Item[j]->Type, pszFieldType, 10);
But just dont know how to determine if a field is PK/FK (primary key and foreign key). and MSDN documentation for VC developers is so bad.
help!
norm
|
|
|
|
|
|
I;m writing a project that works with barcodes. The easiest way to work with them is to use them as font. The problem is that the font must be installes on the client computer.
Well, I'm looking for something different, where the user dossn't need to have or install the font, and the solution I came up with is to ave the font as a resource. This way the font will always be shipped with the program. Now the problem is how to use that font. That is, create a font object from a font definition which is a resource.
By the way, I dont want to copy the font to the font directory on the windows system.
Any clues or hints that can help me. Thanks in advance.
Hernan Breinbauer
|
|
|
|
|
|
hi everyone,
in my sdi application, i created the 1st dialog by press on a button. within the 1st dialog, i created the 2nd dialog from the 1st dialog via a button click.. in the 2nd dialog, there is a button in it.. if the button in the 2nd dialog get clicked, the 2nd dialog is destory and returned me back to the 1st dialog.. is there a way to program the dialog so that if i click the button in the 2nd dialog, the 1st and 2nd dialog get to be destoyed at the same time?
|
|
|
|
|
there are many ways to do this, here's an easy one:
add a "bool" member variable to dlg 2. if the user presses the magic button on dlg 2, set that member variable to "true".
when dlg 2 ends, control is returned to dlg 1 (just after the dlg2.DoModal call). so, test dlg2.m_theBoolMemberVariableIJustDescribed. if it's "true" call OnCancel or OnOK.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
thx for the quick response chris.
|
|
|
|
|
Hello,
I am trying to construct a CListView in the LVS_REPORT mode, but I still want an icon at the beginning of each line entry. Is this possible? I can create the listview, and list all the data, but I cannot seem to make the icons appear.
I have written the following code:
Construction of the listview:
int CLPSListView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
lpCreateStruct->style |= LVS_REPORT;
if (CListView::OnCreate(lpCreateStruct) == -1)
return -1;
// Give the document a pointer to this view
GetDocument()->m_pListView = this;
return 0;
}
In another function where I initialise the data, I create the CImageList, and also the CListCtrlEx, which is a helper class for listviews I found in the MFC Help:
CListCtrlEx& ctlList = (CListCtrlEx&) GetListCtrl();
m_ctlImage.Create(16,16,ILC_COLOR,0,3);
HICON PTIcon = theApp.LoadIcon(IDB_CLOSED);
ASSERT(PTIcon);
m_ctlImage.Add(PTIcon);
PTIcon = theApp.LoadIcon(IDB_OPEN);
m_ctlImage.Add(PTIcon);
ctlList.SetImageList(&m_ctlImage);
I create the columns, no problem, and then use the CListCtrlEx method Additem:
var = rs.GetFieldValue("Readfld");
ctlList.AddItem(nItem,0,CCrack::strVARIANT(var),0);
The last zero refers to the imagelist index.
For completeness I attach the AddItem code in CListCtrlEx:-
BOOL CListCtrlEx::AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex)
{
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nItem;
lvItem.iSubItem = nSubItem;
lvItem.pszText = (LPTSTR) strItem;
if(nImageIndex != -1){
lvItem.mask |= LVIF_IMAGE;
lvItem.iImage |= LVIF_IMAGE;
}
if(nSubItem == 0)
return InsertItem(&lvItem);
return SetItem(&lvItem);
}
I would be very grateful to anyone who can suggest how to make the icon appear at the beginning of the line in this Report mode.
Thanks,
Paul Trimming
|
|
|
|
|
ListView_SetImageList(hwnd, ImgListHandle, LVSIL_SMALL);
|
|
|
|
|
Thanks for your reply, Roman.
By adding LVSIL_SMALL
(ctlList.SetImageList(&m_ctlImage1,LVSIL_SMALL);)
I got the listview to display the first loaded icon. (In the imagelist there are two different icons.) But the strange thing is that I have to put -1 in the actual line where I add the listitem, as follows:
ctlList.AddItem(nItem,NULL,CCrack::strVARIANT(var),-1);
If I put anything else, the icon disappears!!
As I have two icons in the imagelist, I should have thought I should put 0 or 1 in, and I should be able to vary which icon appears. (The -1 entry is the default.)
I would be most grateful for help as to why this is happening.
Thanks,
trimtrom
|
|
|
|
|
I'm trying....to write a program to compute phone bill with discounts and taxes....I got stumped though... I can't have the time with a 60 in it....How do I go about putting this in my code...and I need to compute to Taxes....I need to compute for before the taxes are added in with discounts where needed and with the tax after wards....any help would be grateful....
thanks
Julie
// Purpose: Write a program that computes a phone bill for long distance. Program will ask user to input the number of calls to process.
// Then for each call the user will input the start time for a call based on a 24-hour military time clock and
// length of the call in minutes. The program then will compute and print the cost fo the call, before and after
// the tax has been added. Tax will be computed after discounts (where needed).
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
const float REGULAR_RATE = 0.20f;
const float AFTER_BEFORE = 0.25f;
const float LONGER_SIXTY = .15f;
void DisplayOpeningScreen();
void PrintBlankLines(int);
void PrintTotalBeforeTax(float, int);
void PrintTotalAfterTax(float, int);
int main()
{
int numofCalls;
int callCount;
int startTime;
int lengthinMin;
float sumofCalls;
float callcost;
float discrate1;
float discrate2;
float doubleDisc;
DisplayOpeningScreen();
cout << "How many phone calls will be processed? ";
cin >> numofCalls;
PrintBlankLines(2);
callCount = 0;
sumofCalls = 0;
while (callCount < numofCalls)
{
cout << "The start time of the call in military time is: ";
cin >> startTime;
cout << endl;
while (startTime > 2359 || startTime <0 )
{
cout << "Error.....please enter a vaild start time: \n";
cin >> startTime;
}
cout << "The length of the call in minutes is: ";
cin >> lengthinMin;
cout <<endl;
="" while="" (lengthinmin="" <="" 1)
="" {
="" cout="" <<="" "error....please="" enter="" a="" vaild="" length="" time:="" \n";
="" cin="">> lengthinMin;
}
callcost = lengthinMin * REGULAR_RATE;
if (startTime >= 1800 || startTime < 800)
{
cout << "The call receives a 25% discount\n";
discrate1 = (lengthinMin * AFTER_BEFORE) - float(callcost) ;
cout << "The call with the discount is: " << discrate1 << endl;
}
if (lengthinMin >= 60)
{
cout << "The call receives a 15% discount\n";
discrate2 = float(callcost) - (lengthinMin * LONGER_SIXTY);
cout << "The call with the discount is: " << discrate2 << endl;
}
if (startTime >= 1800 || startTime < 800 && lengthinMin >+60)
{
doubleDisc = discrate1 + discrate2;
cout << "This call receives both a 15% discount and a 25% discount.\n";
cout << "The call with both discounts is: " << doubleDisc << endl;
}
callCount++;
}
PrintTotalBeforeTax(callcost, numofCalls);
return 0;
}
//****************************************************************************************************************************************
void DisplayOpeningScreen()
// Purpose: Explains the program to the user
// Pre: None
{
cout << "/n \"Long Distance Phone Bills\"\n";
PrintBlankLines(3);
cout << "This Program will start by asking you the user to enter the number of calls to be processed. Then you will be asked " << endl;
cout << "to enter the start time for each call based on a 24-hour (military time) clock and the length of the call in minutes.\n\n";
cout << "The program will then compute and print the cost of the call, before and after the federal tax has been addded. Any and all\n";
cout << "discounts will be computed before the federal tax.\n\n";
cout << "The Rate Structure for long distance calls is as follows:\n\n";
cout << " * The regular rate for a call is $" << REGULAR_RATE << " per minute " << endl;
cout << " * Any call started at or after 6:00p.m. (1800 hours) but before 8:00a.m. (800 hous)\n";
cout << " receives a 25% discount" << endl;
cout << " * Any call longer than 60 minutes receives a 15% discount on its cost (after the start\n";
cout << " time discount is subtracted, if appropriate)" << endl;
cout << " * All calls are subject to 4% federal tax, which is computed after the discounts\n\n";
PrintBlankLines(4);
system("pause");
system("cls");
}
//******************************************************************************************************************************************
void PrintBlankLines(/*in*/ int numLines)
// Purpose: Print numLines blank lines on the output screen
// Pre: numlines > 0
{
int lineCt;
lineCt = 1;
while (lineCt <= numLines)
{
cout << endl;
lineCt++;
}
}
//******************************************************************************************************************************************
void PrintTotalBeforeTax(/*in*/ float callcost, /*in*/ int numofCalls)
// Purpose: Prints the total cost of all of the calls inputed by user with out federal tax added on.
// Pre: callcost >= 0.00, num >= 0
{
system("pause");
system("cls");
PrintBlankLines(8);
cout << " Final Totals Before Tax\n\n";
cout << " Number of Calls Processed: " << numofCalls << endl;
cout << " Total amount of calls before tax: " << callcost << endl;
PrintBlankLines(9);
}
//********************************************************************************************************************************************
|
|
|
|
|
Autumn wrote:
#include
#include
#include
using namespace std;
You need to use the formatting buttons above the emoticons below to add < and >, or check "Display message as is' above your signature below. I presume you added stdafx, iostream and what else ?
Also, using namespace std makes namespaces redundant. You should instead have
using std::cout;
using std::cin;
using std::endl;
etc.
The way I format the above code block is to wrap it in a <pre> tag.
Autumn wrote:
while (callCount < numofCalls)
Because you already know the desired range before you start, this would be better as a for loop.
Also, I think your cin calls are failing, probably because you don't call cin.flush(). I entered one number and got full output of everything.
Autumn wrote:
void PrintBlankLines(/*in*/ int numLines)
// Purpose: Print numLines blank lines on the output screen
// Pre: numlines > 0
{
int lineCt;
lineCt = 1;
while (lineCt <= numLines)
{
cout << endl;
lineCt++;
}
}
Again, this would be better as a for loop. You should also always set your variables a value when you create them, although in this case you do that in the second line, the two should be combined.
Also, endl does a flush as well as a new line. This is expensive, and should be avoided. cout << "\r\n" instead to avoid this extra penalty, and if ( as I suspect ) you're doing this for a class, comment the reason you've done so.
I presume your main problem is that you're having trouble calculating times because they cannot be greater than 59 for minutes ? I can't see where in the code you want to do this, but why can't you just do a while loop subtracting 60 from the minutes while they are > 60, and adding 1 to the hours every time ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
You are correct this is for a class....sometimes I just think to hard and get a block. I uderstand with the 60 but what i need is a error loop so if the user prints a 60 then an wrror message appears.... but if I do <60 then it won't let me process any number higher than 60? Any ideas for a code....Thank Christian!!
Autumn
|
|
|
|
|
Autunmsky wrote:
sometimes I just think to hard and get a block.
*grin* I know what you mean.
Autunmsky wrote:
I uderstand with the 60 but what i need is a error loop so if the user prints a 60 then an wrror message appears.... but if I do <60 then it won't let me process any number higher than 60?
Well, say that the numer of hours is stored as m_hours, and the number of minutes as m_minutes, then you could do this:
if (m_minutes > 59)
{
cout << "Value entered greater than 59 minutes, converting to hours"
while(m_minutes > 59)
{
++m_hours;
m_minutes -= 60;
cout << ".";
}
cout << std::endl;
}
Ideally, you would probably ask the user if they want to re-enter the value, I'd think it's more likely to be an error. The easiest way to do this would be as follows:
int m_minutes = 0;
cout << "Please enter the number of minutes (0-59)";
do
{
cin >> m_minutes;
if (m_minutes < 0 || m_minutes > 59) cout "Invalid number entered, please try again ";
cin.flush();
} while (m_minutes < 0 || m_minutes > 59);
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Thanks once a again Christian.....you make it looks so easy!! Now how would I get my program to calcute the totals with and without tax.....would I just use my total sums of calls and then add tax....but how would get the discounts to calc. the price of the call and add it to my total? Or Am I just losing my mind??
Autumn
|
|
|
|
|
Autunmsky wrote:
would I just use my total sums of calls and then add tax
Yes, I'd declare a variable for the total, the another for the total with tax, and simply set that to be the total, then add tax.
Autunmsky wrote:
but how would get the discounts to calc. the price of the call and add it to my total?
I'm not sure what you're tryng to do ? Could you break it down into a step by step process of what needs to be calculated and displayed, so I see what it is you want to end up with ?
Autunmsky wrote:
Or Am I just losing my mind??
I'm afraid I'm not qualified to comment there. :P
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
ok here we go.....what i need to do it.....apply the discounts where needed which is already in the program. What i need it to do is give me the cost of the call with the discount...or discounts. Then at the end...final screen I need to show the cost of all of the calls before tax and the cost of the calls after tax.....but all discounts have to be applied before the cost of all of the calls beofre and after tax...does this help??
Autumn
|
|
|
|
|
So you need to keep the cost of the calls with discounts applied in one variable, and the discounts themselves in another variable, and then if you ever need to know the cost of the calls before discounts ( which seems not to happen too often, hence my suggestion that you do it this way ), then you can just add the discounts to the call costs.
Does that do it ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
i think that makes sense...now i just have to code it ....with the 60 thing again....I have to do it in Military time....so if the user types 1860 I need it to send at error message....would I still do that the same way you suggested to do it before?
Autumn
|
|
|
|
|
Your system overall is very fragile, I personally would have strings entered and then look for spaces or : or ., before chopping up the numbers. But it will work like this, just make sure the number is no more than 4 digits long, then to get the minutes you would say
minutes = total & 99;
and
hours = total - minutes;
I believe that's right, anyhow.
Once you have minutes and seconds, I would be more inclined to have the UI report an invalid number and ask again, because it's unlikely someone would deliberately enter 1375 for 2:15 pm, but if you prefer to roll the values around, yes that is how I would do it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|