|
I do have it like that. i just posted it wrong. sorry about that.
- Kyle
-- modified at 13:13 Sunday 30th October, 2005
|
|
|
|
|
How and where are you including this XML file?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: How and where are you including this XML file?
i am including it with #include "file.xml" at the top of my code.
is that wrong?
- Kyle
|
|
|
|
|
gr8coaster329 wrote: is that wrong?
Very much so. You can, however, include it as a resource in the project's .rc file.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I have a form. I can convert that form to a bmp and
print user data and the bitmap together so that data prints
on top of the bitmap. The problem is, bitmaps print
extremely slowly (and their really big).
Any ideas on how to print the data on top of an
image quicker without programmatically recreating the
form?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
Is your app an MFC app ? If so, did you create it with support for printing ? You could create a new app with printing support to see the code you'd need to add to your app.
Alternatively, there are a number of good articles on C++ printing, with and without MFC, in the C++ section.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
> Is your app an MFC app ?
I havent created the final app yet. In the end, I hope its in
MFC.
> If so, did you create it with support for printing ? You could
> create a new app with printing support to see the code you'd need
> to add to your app.
I setup a smaller program that uses the Printing Class Library
that Richard Stringer posted. In that code, I can print a bitmap
and text together and it prints nicely. I can prompt user data
and then have that overlay the bitmap.
However, the bigger and more complicated the bitmap, the slower it
takes to print and I need big (lots of pixels) bitmaps to include
all the detail of the form. I cant figure out how to change
Stringer's printing class library to print some other image format like a tiff. If I could modify that code to print a tiff (and a
bitmap) that could overlay text, then it might print faster and
Id be happy.
If you have any ideas, please dont hesistate to email me.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: I havent created the final app yet. In the end, I hope its in
MFC.
OK, when you create your app, you can choose printing support from the wizard, this gives you the framework you need to do printing, and there's heaps of info online about using it.
DanYELL wrote: However, the bigger and more complicated the bitmap, the slower it
takes to print and I need big (lots of pixels) bitmaps to include
all the detail of the form. I cant figure out how to change
Stringer's printing class library to print some other image format like a tiff. If I could modify that code to print a tiff (and a
bitmap) that could overlay text, then it might print faster and
Id be happy.
Some printers will let you send a tiff, but I don't know how many. If you want to draw on the bitmap, then it needs to be a bmp in memory. I really don't know how to stream a tiff to a printer, although obviously the first step would be reading it as a byte stream.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Anybody knows how to get SPDRP_FRIENDLYNAME in SetupDiGetDeviceRegistryProperty from USB disk, the buffer I get always invalid?In addition Can It works under Win98?
DEFINE_GUID(GUID_CLASS_USB_DEVICE,
0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED);
hDevInfo = SetupDiGetClassDevs((LPGUID)&GUID_CLASS_USB_DEVICE,
0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (hDevInfo == INVALID_HANDLE_VALUE)
return false;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i = 0 ; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData) ; i++)
{
DWORD DataT;
LPTSTR buffer = new char[1024];
DWORD buffersize = 1024;
SetupDiEnumDeviceInterfaces (hDevInfo, 0, &DeviceInfoData.ClassGuid, i, &DInfoData);
while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData,
SPDRP_FRIENDLYNAME, &DataT, (PBYTE)buffer, buffersize, &buffersize))
...
}
|
|
|
|
|
Hello,
I'm writing an application that uses MFC.
It is a kind of media player and I use CListCtrl to display playlist.
But I get a strange error when I add items to my list control. After the 17th item added, my app crashs with a message box showing "Invalid Hook Descriptor".
I am attaching some code. To keep it simple, I've just extracted parts liable to contain the bad code : the overrided Create member method and the UpdateList method.
An explanation : I'm displaying playlist. So I read the M3U file and I call Update list method to add the file paths to the CListCtrl.
Any help would be appreciated. That bug is driving me crazy.
Thanks
bool CMusicBox::CreateWnd(CWnd* Parent)<br />
{<br />
parent = Parent;<br />
if(parent)<br />
{<br />
<br />
RECT client;<br />
parent->GetClientRect(&client);<br />
int result = this->Create(WS_CHILD|WS_VSCROLL|WS_BORDER|WS_VISIBLE|LVS_SHOWSELALWAYS|LVS_REPORT|LVS_ALIGNLEFT,client,parent,1234);<br />
this->SetExtendedStyle(0x00004000|0x00000100|0x00000020|0x00000010);<br />
<br />
this->SetBkColor(RGB(237,242,249));<br />
}<br />
The UpdateList method
void CMusicBox::UpdateList(void)<br />
{<br />
this->DeleteAllItems();<br />
ASSERT(this->GetItemCount() == 0);<br />
int max = this->play.playList.GetCount();<br />
<br />
this->SetItemCount(max);<br />
<br />
int i = 0;<br />
<br />
for(i = 0;i<max;i++)<br />
{<br />
CFile myFile;<br />
<br />
CString title;
CString path;<br />
unsigned long siz = 0;<br />
<br />
if(myFile.Open(this->play.GetSong(i),CFile::modeRead|CFile::shareDenyNone))<br />
{<br />
title = myFile.GetFileTitle();<br />
siz = myFile.GetLength();<br />
myFile.Close();<br />
}<br />
else {<br />
title.Format("Access Denied");<br />
}<br />
HMS dure = {0,0,0};<br />
<br />
path = CString(this->play.GetSong(i));<br />
<br />
HWND tester = MCIWndCreate(NULL,AfxGetInstanceHandle(),WS_BORDER|MCIWNDF_NOERRORDLG,path.GetString());<br />
if(tester)<br />
{<br />
long len = MCIWndGetLength(tester);<br />
dure = GetHMSTime(len);<br />
MCIWndDestroy(tester);<br />
}<br />
<br />
char *taille = new char[50];<br />
char *duree = new char[50];<br />
char *chemin = new char[MAX_PATH];<br />
char *titre = new char[MAX_PATH];<br />
<br />
sprintf(taille,"%.2f",siz/(1024.0*1024));<br />
if(dure.h == 0) <br />
sprintf(duree,"%d : %02d", dure.m, dure.s);<br />
else sprintf(duree,"%d : %02d : %02d",dure.h, dure.m, dure.s);<br />
strcpy(chemin, path.GetString() );<br />
<br />
CPath filePath(path);<br />
<br />
sprintf(titre,"%s",filePath.GetTitle());<br />
<br />
LVITEM lvi;<br />
<br />
ZeroMemory(&lvi,sizeof(LVITEM));<br />
<br />
lvi.mask = LVIF_TEXT;<br />
<br />
this->InsertItem(i,"item");<br />
<br />
this->SetItem(i,0,LVIF_TEXT,titre,NULL,NULL,NULL,NULL);<br />
this->SetItem(i,1,LVIF_TEXT,duree,NULL,NULL,NULL,NULL);<br />
this->SetItem(i,2,LVIF_TEXT,chemin,NULL,NULL,NULL,NULL);<br />
this->SetItem(i,3,LVIF_TEXT,taille,NULL,NULL,NULL,NULL);<br />
<br />
<br />
}<br />
}<br />
-- modified at 21:05 Saturday 29th October, 2005
|
|
|
|
|
hi,
beginner question: how would I implement a "number picker" control where there is an up/down button (like from a vertical scrollbar) and as you click up the number increments by one, down decrements by one until it hits zero, then when I hit ok it gives me the number I chose. Thanks!
|
|
|
|
|
Look up Up-Down Controls in MSDN. (The CSpinButtonCtrl class if you're using MFC.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks, that worked! One question, the up arrow makes the numbers decrease, and the down arrow makes them increase. Any way to reverse that? Thanks again!
|
|
|
|
|
That's the default behavior. You have to manualy set the range, direction and all that. You can even set an acceleration--how it goes slow at first then speeds up. You can also set whether to insert a thousands separator if appropriate.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
i have a struct array:
typedef struct _PERSON
{
TCHAR *firstName;
TCHAR *lastName;
TCHAR *address;
TCHAR *phone;
} PERSON;
which a properly alloc in annn array of people[10]
then i call:
myAddressBook *book = new myAddressBook(_T("first"),_T("slast"),_T("phone"),_T("add"));
book->addPerson(_T("first"),_T("aaaaa"),_T("phone"),_T("add"));
book->addPerson(_T("first"),_T("bbbbb"),_T("phone"),_T("add"));
book->addPerson(_T("first"),_T("ddddd"),_T("phone"),_T("add"));
book->addPerson(_T("first"),_T("ccccc"),_T("phone"),_T("add"));
book->sortPeople(book->people,book->mTotal);
heres the func:
void myAddressBook::sortPeople(PERSON *per, int num)
{
PERSON *temp;
for (int x=0;x<(mTotal-1); x++)
{
if (_tcsncmp(per[x].lastName, per[x+1].lastName, _tcslen(per[x].lastName)) > 0)
{
//str2 is biggerr, so- swap em
temp = &per[x];
per[x] = per[x+1];
per[x+1] = *temp;
}
}
}
the results are not right, duplicated entries and other oddness, whats wrong?
|
|
|
|
|
kerrywes wrote: per[x+1] = *temp;
that doesn't seem right.
shouldn't it be "per[x+1]=temp;"
i assume per is an array of pointers to PERSONs
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
The fault is with the the copy routines.
temp = &per[x] gets just a pointer but then per[x] = per[x+1] does a copy, destroying the original data. You need to force copies for each of the swap operations. You also need to make temp a value, not a pointer.
temp = per[x];
per[x] = per[x+1];
per[x+1] = temp;
Ultimately, this realy doesn't do a sort, though. It just does a single pass through the array. Look up bubble sort to learn how to do a very basic sort.
(Generally, using qsort, or some version thereof, would be better.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
1. kerrywes wrote: {
2. //str2 is biggerr, so- swap em
3. temp = &per[x];
4. per[x] = per[x+1];
5. per[x+1] = *temp;
6. }
Hi
In 3 you save the address of per[x] but replace the content of that !
must change to
{<br />
*temp = per[x];<br />
per[x] = per[x+1];<br />
per[x+1] = *temp;<br />
}
but in this case you have a problem that the temp is pointer, you most declere it as
PERSON temp;
Iman Ghasrfakhri
-- modified at 1:12 Sunday 30th October, 2005
|
|
|
|
|
hi everybody , ive used the code published here( named w3client) to connect to hotmail and tried to login to ,but it dosent work. can anyone help please ?
url="https://login.passport.com";
_pclient->Request("/ppsecure/post.srf", W3Client::reqPost);
_pclient->AddPostArgument("login","MyLogin");
_pclient->AddPostArgument("passwd","MyPassword");
_pclient->AddPostArgument("id","2");
_pclient->AddPostArgument("svc","mail");
_pclient->AddPostArgument("msppjph","1");
_pclient->AddPostArgument("tw","0");
_pclient->AddPostArgument("fs","1");
_pclient->AddPostArgument("fsa","1");
_pclient->AddPostArgument("fsat","1296000");
_pclient->AddPostArgument("lc","1033");
_pclient->AddPostArgument("_lang","EN");
_pclient->AddPostArgument("bk","1130609581");
_pclient->AddPostArgument("SI","++++Sign+In++++");
_pclient->Request("/ppsecure/post.srf", W3Client::reqPost);
the hotmail html code for the form looks like that :
// method="post" action = "..
//https://login.passport.com/ppsecure/post.srf?id=2&svc=mail&msppjph=1
//&tw=0&fs=1&fsa=1&fsat=1296000&lc=1033&_lang=EN&bk=1130606198
|
|
|
|
|
what is the way to identify the file system type- FAT or NTFS or something else - any API?
thanks!
|
|
|
|
|
|
Hi
I got an app - all works fine including tooltips for ctrls.
Now i want to add Tooltips for my owner drawn objects.
I got the
void MyAppView::OnDraw(CDC* pDC)
{
// Raute
pDC->MoveTo(20,30);
pDC->LineTo(24,25);
pDC->LineTo(20,20);
pDC->LineTo(24,35);
pDC->LineTo(20,30);
}
Now i want to Tooltip "Raute" the cursor is inside this area
But nothing happens?
Using "myAppView::OnToolHitTest(...){...}" does not display anything.
THX
Tim
|
|
|
|
|
hello list, i am having some trouble with thread sinc in a multithread program i am developing.
the problems is i dont know how many threads i will have in my program, here is some code:
void CAsyncClientDlg::CleanupThread()
{
CString n;
GetDlgItemText(IDC_SIMULTANEOS, n);
int a = _ttoi(n.GetBuffer(n.GetLength()));
for(LONG i=0; i<a; i++)="" {
="" if="" (m_pclientthread[i])
="" {=""
="" (::postthreadmessage(m_pclientthread[i]-="">m_nThreadID, WM_TERM_THREAD, 0, 0) == 0)
TRACE(_TEXT("Thread 0x%02x possibly already terminated\n"), m_pClientThread[i]->m_nThreadID);
// wait up to 1s for secondary threads to terminate
// termEvent will be signaled when thread count reaches 0
if (termEvent.Lock(1000))
TRACE(_TEXT("Threads terminated gracefully\n"));
else
TRACE(_TEXT("WARNING: All secondary thread(s) not gracefully terminated.\n"));
}
}
}
void CAsyncClientDlg::OnConnect()
{
CString str;
GetDlgItemText(IDC_SERVERNAME, str);
CString n;
GetDlgItemText(IDC_SIMULTANEOS, n);
int a = _ttoi(n.GetBuffer(n.GetLength()));
// validate that the number is <= MAX_NUMBER_OF_THREADS
for(LONG variable=0; variable<a; variable++)="" {
=""
="" create="" a="" thread="" to="" handle="" the="" connection.="" is="" created="" suspended="" so="" that="" we="" can
="" set="" variables="" in="" cclientthread="" before="" it="" starts="" executing.
="" cclientthread*="" pthread="(CClientThread*)AfxBeginThread(RUNTIME_CLASS(CClientThread)," thread_priority_normal,="" 0,="" create_suspended);
="" if="" (!pthread)
="" setdlgitemtext(idc_connectionstatus,="" cstring("could="" not="" connected="" ")="" +="" str);
="" trace(_text("could="" thread\n"));
="" return;
="" }
="" trace(_text("casyncclientdlg::onconnect()\n"));
="" getdlgitem(idc_connect)-="">EnableWindow(FALSE);
m_strServerName = str;
pThread->m_strServerName = str; // server machine name
pThread->m_socket.m_pThread = pThread; // the thread that m_socket lives
m_pClientThread[variable] = pThread; // keep a pointer to the connect socket thread
pThread->m_socket.CreateConnector(m_pContext);
// Now start the thread.
pThread->ResumeThread();
}
}
void CAsyncClientDlg::OnDisconnect()
{
CString n;
GetDlgItemText(IDC_SIMULTANEOS, n);
int a = _ttoi(n.GetBuffer(n.GetLength()));
for(LONG i=0; i<a; i++)="" {
="" if="" (m_pclientthread[i])
="" (::postthreadmessage(m_pclientthread[i]-="">m_nThreadID, WM_TERM_THREAD, 0, 0) == 0)
TRACE(_TEXT("Thread 0x%02x possibly already terminated\n"), m_pClientThread[i]->m_nThreadID);
}
}
}
LRESULT CAsyncClientDlg::OnConnectionClose(WPARAM, LPARAM)
{
CString n;
GetDlgItemText(IDC_SIMULTANEOS, n);
int a = _ttoi(n.GetBuffer(n.GetLength()));
for(LONG i=0; i<a; i++)="" {
="" m_pclientthread[i]="NULL;
" }
}
lresult="" casyncclientdlg::onnewmessage(wparam="" wparam,="" lparam)
{
="" cstring="" strrecv="CString((TCHAR" *)wparam);
="" m_received="m_received" +="" strrecv;
="" updatedata(false);
=""
="" return="" 0l;
}
void="" casyncclientdlg::onmail()=""
{
="" n;
="" getdlgitemtext(idc_simultaneos,="" n);
="" int="" a="_ttoi(n.GetBuffer(n.GetLength()));
" for(long="" variable="0;" variable<a;="" variable++)="" if="" (m_pclientthread[variable]="" &&="" (m_pclientthread[variable]-="">m_socket).m_fConnected)
{
CString str, desde, hasta, subject, mensaje, cdesde, cresponder;
GetDlgItemText(IDC_EDESDE, desde);
GetDlgItemText(IDC_ESUBJECT, subject);
GetDlgItemText(IDC_EMENSAJE, mensaje);
GetDlgItemText(IDC_CABDESDE, cdesde);
GetDlgItemText(IDC_CABRESPONDER, cresponder);
str = "ehlo hola\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "auth plain password\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "mail from: <" + desde + ">\r\n"; // nrcpt to: <" + hasta + ">\r\n\r\data\r\nSubject: " + subject + "\r\n\r\n" + mensaje + "\r\n.\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
int numero = m_hasta.GetCount();
for(int k=0; k<numero; k++)="" {
="" m_hasta.gettext(k,="" hasta);
="" str="rcpt to: <" +="" hasta="" "="">\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
MessageBox(hasta);
}
str = "data\r\n";
(m_pClientThread[variable]->m_socket).WriteWebRequest(str);
str = "Subject: " + subject + "\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "From: " + cdesde + "<" + desde + ">\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "In-Reply-To: " + cresponder + "\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "\r\n" + mensaje + "\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "\r\n.\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
str = "quit\r\n";
(m_pClientThread[variable]->m_socket).Write(str);
}
else
{
}
SetDlgItemText(IDC_CONNECTIONSTATUS, "No Connectado");
}
}
The problem is sometimes all the strings on "OnMail" functions goes to the server and i can see the answers on my received windows.
For example when IDC_SIMULTANEOS = 1(1 thread) its works fine.
When threads are bigger than 1 the results on my received window are disordered, here is an example of 2 simultaneous threads sending 3 mails each.
220 mx.gmail.com ESMTP h39sm756279wxd
250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
235 2.7.0 Accepted
250 2.1.0 OK
250 2.1.5 OK
250 2.1.5 OK
250 2.1.5 OK
354 Go ahead
220 mx.gmail.com ESMTP h14sm686078wxd
250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
235 2.7.0 Accepted
250 2.1.0 OK
250 2.0.0 OK 1130593300 h39sm756279wxd
250 2.1.5 OK
250 2.1.5 OK
250 2.1.5 OK
354 Go ahead
250 2.0.0 OK 1130593300 h14sm686078wxd
Thats fine to me, all the commands get executed on the server but sometimes:(same example 2 simultaneous threads sending 3 mails each):
220 mx.gmail.com ESMTP i38sm758995wxd
502 5.5.1 Unrecognized command i38sm758995wxd
250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
235 2.7.0 Accepted
250 2.1.0 OK
250 2.1.5 OK
250 2.1.5 OK
250 2.1.5 OK
354 Go ahead
250 2.0.0 OK 1130593502 i38sm758995wxd
220 mx.gmail.com ESMTP h9sm717398wxd
502 5.5.1 Unrecognized command h9sm717398wxd
250-mx.gmail.com at your service
250-SIZE 20971520
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
The flow was stopped and only 3 mails were send.
My question is why this works well sometimes and sometimes dont if i am inserting the sames values?
I think i can solve it with an event but i dont know where to set and unset.
I search documentation but i never see how to works with threads created like this.
Thanx in advance.
|
|
|
|
|
When does OnMail get called? If it can get called from multiple threads, then that explains the jumbled order. Also, each thread will read whatever is available in the UI at *that* point of time, maybe that explains the "invalid command" errors?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
thanx for the answer.
onconnect gets called when the users press the "connect botton" and onmail is called when the user press the "sendmail" button.
the invalid commands are becouse in a previous version of the program i put an "\r\n" justo before the "ehlo" and the server take that as invalid.
i think i copy the second receive window that version of the programa but the problem is the same in the new one without the unrecognized commands.
thanx again and i hope help.
|
|
|
|
|