|
|
My company has a NT domain server, connected by Windows 9x/Me clients. I want to write a program checking the user's group for authorization. Which WinAPI function can provide such information for window 9x/Me clients? Thanks.
Ruxo Zheng
|
|
|
|
|
hi everyone,
my sdi application is base on listview and the contents displayed in the listview are retrieved from a database.. the database is accessed via odbc.. i use a dialog to gather input information.. whenever the information is submitted from the dialog, i created a crecordset/odbc object within the additem function in the dialog class and make sql insert call within the dialog class.. i called the updateallviews function from the sdi/listview right after the new new data is stored in the database, ie when the dialog get destroyed..
i'm getting the database update delay problem.. whenever i call updateallviews, the content of the listview doesn't get updated(the newly added item doesn't show up) until i call updateallviews the 2nd time.. does anyone know how to solve this database delay problem? thx!
|
|
|
|
|
To All,
I am using SetItemText after the column is properly inserted and the InsertItem function is called. The Scrollbar shows that the rows have been inserted, but I can't see any text when using SetItemText. What a headache. What should I do?
|
|
|
|
|
David Kadish wrote:
What should I do?
You should write with what type of control you work. It is a ListView? Show a code. Do you think we have a telepathy?
|
|
|
|
|
The List control can be a little bit quirky sometimes. Not knowing what your code looks like makes it a little difficult to diagnose, but here is my InsertItem/SetItemText code for a front-end application to a DVD collection database:
for( int i = 0; i < m_titles.GetSize(); ++i )
{
CMovieTitle* title = (CMovieTitle*)m_titles[i];
int itemCount = m_movieList.GetItemCount();
m_movieList.InsertItem(itemCount, title->m_sTitle ,0);
m_movieList.SetItemText(itemCount,1,title->m_sFormat);
m_movieList.SetItemText(itemCount,2,title->m_sRegionCode);
m_movieList.SetItemText(itemCount,3,title->m_sRating);
m_movieList.SetItemText(itemCount,4,title->m_sReleaseDate);
m_movieList.SetItemText(itemCount,5,title->m_sVideoReleaseDate);
m_movieList.SetItemText(itemCount,6,title->m_sStudio);
m_movieList.SetItemText(itemCount,7,title->m_sPresentation);
m_movieList.SetItemText(itemCount,8,title->m_sFeatures);
m_movieList.SetItemText(itemCount,9,title->m_sSound);
m_movieList.SetItemText(itemCount,10,title->m_sLanguage);
m_movieList.SetItemText(itemCount,11,title->m_sDuration);
}
CMovieTitle is a wrapper class that I use to hold one record from the database. In this example I am iterating through all of the records and inserting the data into a list control.
You also may be interested in how I am initializing my list control. Here's my code from OnInitDialog (my app is a dialog app):
m_movieList.InsertColumn( 0, "Movie Title", LVCFMT_LEFT, -1, 0);
m_movieList.InsertColumn( 1, "Format", LVCFMT_LEFT, -1, 1);
m_movieList.InsertColumn( 2, "Region Code", LVCFMT_LEFT, -1, 2);
m_movieList.InsertColumn( 3, "Rating", LVCFMT_LEFT, -1, 3);
m_movieList.InsertColumn( 4, "Release Date", LVCFMT_LEFT, -1, 4);
m_movieList.InsertColumn( 5, "Video Release Date", LVCFMT_LEFT, -1, 5);
m_movieList.InsertColumn( 6, "Studio", LVCFMT_LEFT, -1, 6);
m_movieList.InsertColumn( 7, "Presentation", LVCFMT_LEFT, -1, 7);
m_movieList.InsertColumn( 8, "Sound", LVCFMT_LEFT, -1, 8);
m_movieList.InsertColumn( 9, "Features", LVCFMT_LEFT, -1, 9);
m_movieList.InsertColumn( 10, "Language", LVCFMT_LEFT, -1, 10);
m_movieList.InsertColumn( 11, "Duration", LVCFMT_LEFT, -1, 11);
m_movieList.SetColumnWidth( 0, 60 );
m_movieList.SetColumnWidth( 1, 60 );
m_movieList.SetColumnWidth( 2, 60 );
m_movieList.SetColumnWidth( 3, 60 );
m_movieList.SetColumnWidth( 4, 60 );
m_movieList.SetColumnWidth( 5, 60 );
m_movieList.SetColumnWidth( 6, 60 );
m_movieList.SetColumnWidth( 7, 60 );
m_movieList.SetColumnWidth( 8, 60 );
m_movieList.SetColumnWidth( 9, 60 );
m_movieList.SetColumnWidth( 10, 60 );
m_movieList.SetColumnWidth( 11, 60 );
I hope this helps. If you have questions after looking at my code (which has been tested, BTW), feel free to send them my way.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
perlmunger wrote:
m_movieList.SetColumnWidth( 0, 60 ); m_movieList.SetColumnWidth( 1, 60 ); m_movieList.SetColumnWidth( 2, 60 ); m_movieList.SetColumnWidth( 3, 60 ); m_movieList.SetColumnWidth( 4, 60 ); m_movieList.SetColumnWidth( 5, 60 ); m_movieList.SetColumnWidth( 6, 60 ); m_movieList.SetColumnWidth( 7, 60 ); m_movieList.SetColumnWidth( 8, 60 ); m_movieList.SetColumnWidth( 9, 60 ); m_movieList.SetColumnWidth( 10, 60 ); m_movieList.SetColumnWidth( 11, 60 );
Hi Matt,
Ever heard about that for{} instruction ;P;P?
~RaGE();
|
|
|
|
|
Ever heard how inefficient for loops are? Might be tidy, but it is certainly slower. Not to mention, my column widths may not always be equal.
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
My computer have two VGA adapter ( No.1, No.2 ), set No.1 to the main display, No.2 is free, I want capture the content of No.1, then make some transform and copy to No.2.
The puzzle is, how to identify No.2( or No.3, No.4.. ), as far as know the function GetDC( NULL ) can get desktop( main display ) content.
|
|
|
|
|
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);
}
//********************************************************************************************************************************************
|
|
|
|
|