|
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.
|
|
|
|
|
When I am creating ImageList for the listctrl which i am trying to implement in dll is throwing some strange error .
m_cImageList.Create(IDB_BITMAP1, 16, 3, RGB(255, 0, 255));
It is throwing error that IDD_Bitmap1 is undeclared.
please help
|| ART OF LIVING ||
|
|
|
|
|
hi ,
few hours before i posted a qurey about file transfer for which i was able to find a solution to close and restart soket in each transfer is this right process have u got another solution then reply to me
thanking u
jobythomas24@gmail.com
jiffthomson@rediffmail.com
sujaisundaresan@yahoo.com
rexy1010@yahoo.com
jobythomas
jobythomas24@gmail.com
|
|
|
|
|
i am alone person working on vc++ and really getting head stucked
it seems you are in group ,please take me with you
|| ART OF LIVING ||
|
|
|
|
|
I'm using mciSendString to play an .avi file.
The problem is if i play the file in fullscreen when i click on the screen it came back in windowed mode but it stop the movie.
Why?
How can i avoid to make came back in windowe mode after click when it is fullscreen?
Or how can i handle a function when it happens so to continue to play the movie?
I hope to be explained good, in contrary case please ask me.
Regards.
|
|
|
|
|
hi,
I want to use a .xml file to store data.The data is to be added and retrived using program(MFC).Pls help me...
Im a beginner in pgming....
Thanks in advance..
Warier
|
|
|
|
|
did you take a piece of your time to search the site ?
see this[^]...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Plz can someone help me? Is it possible to show text in a RichEditCtrl in zoomfactor while editing? (real zoom, not changing fontsize etc)
thx
|
|
|
|
|
I would like to know the simplest way to make a radio button with bitmap on it. Please help!
|
|
|
|
|
if i well remember, you actually trying to put a bitmap on a push-like button (such as a radio or a check box).
you could have a look at my article[^] and look at the "Switch Answers Lists" button.
here is how to proceed. On the OnInitDialog() insert this code :
m_pbAnswersListState = (CButton*) GetDlgItem(IDC_ANSLISTSTATE_CHK);
HICON hIcon;
hIcon = (HICON)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDI_SWITCH),
IMAGE_ICON,
0,
0,
LR_DEFAULTCOLOR);
if (hIcon) {
m_pbAnswersListState->SendMessage(BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
}
in my code, IDI_SWITCH is the ID of my icon, and IDC_ANSLISTSTATE_CHK is the ID of my checkbox (work the same with a radio)...
ok, i use an icon ; for a bitmap, just change the IMAGE_ICON parameter with IMAGE_BITMAP and the HICON with HBITMAP .
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 8:37 Saturday 29th October, 2005
|
|
|
|
|
I would like to know how it implement with button up image and button down image. Also it seems no change with the radio button.
m_logon.GetDlgItem(IDC_RADIO1);
//...
HBITMAP hIcon;
hIcon = (HBITMAP)LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE("TEST_U"),
IMAGE_BITMAP ,
0,
0,
LR_DEFAULTCOLOR);
if (hIcon)
{ m_logon.SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hIcon);}
Please help!
|
|
|
|
|