|
I added style WS_VISIBLE to the pager control and ran it. Still the toolbar is not visible.
I created the pager control from the frame window CMainFrame. So the pager control should be visible from all child windows. See code below:
HWND CMainFrame::CreatePagerControl()
{
//create the pager control
//initialize page control object
LPINITCOMMONCONTROLSEX lpInitCtrls = new INITCOMMONCONTROLSEX;
lpInitCtrls->dwICC =ICC_PAGESCROLLER_CLASS;
lpInitCtrls->dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(lpInitCtrls);
HWND h_pager_control = CreateWindow(WC_PAGESCROLLER,NULL,PGS_HORZ|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, m_hWnd, NULL ,AfxGetInstanceHandle(),NULL);
if ( h_pager_control == NULL)
{
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
AfxMessageBox((LPCTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
}
return h_pager_control;
}
My comments are wrong. It should say can not load toolbar resouce instead of menu resource.
I am not sure about your last question. I added InvalidateRect(NULL)after the pager control was created. It did not help. The pager control is still not visible.
Eilzabeth
|
|
|
|
|
Then I dont really know.
Do you know Spy++? Use that to check if the control is in the parent window. If it is, check its size, position and styles. That could give you some tips on whats wrong.
Or if you like, you can send your projekt (in a zip file) to Shidobu_@hotmail.com and I will check it for you.
I just saw something I missed earlier when I was reading about the pager control. Below is extract from MSDN (short version: you need to handle PGN_CALCSIZE notify message).
************************************************************************
At a minimum, it is necessary to process the PGN_CALCSIZE notification. If you don't process this notification and enter a value for the width or height, the scroll arrows in the pager control will not be displayed. This is because the pager control uses the width or height supplied in the PGN_CALCSIZE notification to determine the "ideal" size of the contained window.
The following example demonstrates how to process the PGN_CALCSIZE notification case. In this example, the contained window is a toolbar control that contains an unknown number of buttons at an unknown size. The example shows how to use the TB_GETMAXSIZE message to determine the size of all of the items in the toolbar. The example then places the width of all of the items into the iWidth member of the NMPGCALCSIZE structure passed to the notification.
case PGN_CALCSIZE:
{
LPNMPGCALCSIZE pCalcSize = (LPNMPGCALCSIZE)lParam;
switch(pCalcSize->dwFlag)
{
case PGF_CALCWIDTH:
{
SIZE size;
SendMessage(hwndToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size);
pCalcSize->iWidth = size.cx;
}
break;
}
}
return 0;
|
|
|
|
|
I have tried all the possibilities I could. But the toolbar is still not showing up. View-ToolBar is never checked in the application. I have sent the project over to you at Shidobu_@hotmail.com. I hope there is a solution for it.
-Elizabeth
Eilzabeth
|
|
|
|
|
I need to create a pager control for the application, which contains the application toolbar. Is OnCreate function at CMainFrame the right place to create it?
Eilzabeth
|
|
|
|
|
Hi
I have a GUI application that does this:
<br />
GUI Thread<br />
AfxBeginThread(...);
AfxBeginThread(...);
I want to capture when both the threads have returned and then enable the Cancel button. What is the most effective way of doing that? I have looked at WaitForMultipleObjects but probably do no know how to implement it.
Thanks in advance
ashish
|
|
|
|
|
You could create a function (in your GUI) to receive a PostMessage from the thread.. that way your application doesn't hang while waiting for the threads to finish.. I could post some code if you want..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks...could you please post.
|
|
|
|
|
I havent compiled any of this so there could be mistakes.. This will allow your threads to post messages to the main GUI..
#define UWM_THREAD_A_DONE WM_APP+1
#define UWM_THREAD_B_DONE WM_APP+2
ON_MESSAGE(UWM_THREAD_A_DONE, OnThreadADone)
ON_MESSAGE(UWM_THREAD_B_DONE, OnThreadBDone)
LRESULT OnThreadADone (WPARAM wParam, LPARAM lParam);
LRESULT OnThreadBDone (WPARAM wParam, LPARAM lParam);
LRESULT CMainFrame::OnThreadADone(WPARAM wParam, LPARAM lParam)
{
return TRUE;
}
LRESULT CMainFrame::OnThreadBDone(WPARAM wParam, LPARAM lParam)
{
return TRUE;
}
Inside the Thread "A" do a PostMessage(UWM_THREAD_A_DONE,0,0);
Hope it helps..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
The following code can be used to test if the threads are still running:
HANDLE hThreads[2];
hThreads[0] =
hThreads[1] =
DWORD dwCode = WaitForMultipleObjects(2,hThreads,TRUE,0);
if ( dwCode == WAIT_TIMEOUT ) {
}
[EDIT]
The 0 in the last parameter of WaitForMultipleObjects indicates to test and return immediately if you want to wait longer you can enter a value or INFINITE to wait until both threads end.
[/EDIT]
John
|
|
|
|
|
John
I actually want both threads to finish, not one of them. So if I use TRUE for Parm 3 of WaitForMultipleObjects, then as soon as one thread exists, won't my statement return?
I acutally tried this:
<br />
HANDLE hEvents[2] = {NULL,NULL};<br />
CWinThread *pThread1,*pThread2;<br />
<br />
try<br />
{ <br />
m_bRestartMode = IsRestartMode();<br />
<br />
if(!m_bRestartMode)<br />
{<br />
if(GetPendingANI() == SAL2UNI_RETCODE_SUCC)<br />
{<br />
pThread1 = AfxBeginThread(BeginWorker,(LPVOID)this);<br />
pThread2 = AfxBeginThread(CRMWorker,(LPVOID)this);<br />
}<br />
}<br />
else<br />
{<br />
if(Restart())<br />
{<br />
pThread1 = AfxBeginThread(BeginWorker,(LPVOID)this);<br />
pThread2 = AfxBeginThread(CRMWorker,(LPVOID)this);<br />
}<br />
}<br />
<br />
hEvents[0] = pThread1->m_hThread;<br />
hEvents[1] = pThread2->m_hThread;<br />
<br />
}<br />
catch(CDaoException *daoe)<br />
{<br />
CString sErrorMsg,sErrNo;<br />
CDaoErrorInfo *errInfo = daoe->m_pErrorInfo;<br />
<br />
<br />
sErrNo.Format("%d", errInfo->m_lErrorCode);<br />
sErrorMsg = "Error No.: " + sErrNo + " - " + errInfo->m_strDescription;<br />
sErrorMsg += " occurred in application " + errInfo->m_strSource;<br />
LogActivity(CA_MSG_SEVERITY_INFORMATION,sErrorMsg);<br />
daoe->Delete();<br />
<br />
}<br />
<br />
WaitForMultipleObjects(2,hEvents,FALSE,INFINITE);<br />
LogActivity(CA_MSG_SEVERITY_INFORMATION,"Both threads returned");<br />
<br />
And my code just got hung....none of the two worker threads did any work and I never got to LogActivity(...) below WaitForMultipleObjects.
Thanks
ashish
|
|
|
|
|
He was probably assuming that you were running this in a loop.. checking every so often to see if both the threads exited.. You could set the Infinate flag and not even use the loop.. then it would wait until both exited.. Could be infinate if for some reason one of your threads hung..
HANDLE hThreads[2];
hThreads[0] =
hThreads[1] =
while(true)
{
DWORD dwCode = WaitForMultipleObjects(2,hThreads,TRUE,100);
if ( dwCode == WAIT_TIMEOUT )
{
}
else
{
break;
}
}
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
achandra007 wrote:
So if I use TRUE for Parm 3 of WaitForMultipleObjects, then as soon as one thread exists, won't my statement return?
You do want TRUE for param 3 because that means to wait for both threads to finish. Are you sure that the threads are finishing? I have used this technique in the past with CreateThread() but not AfxBeginThread but the result should be the same.
John
|
|
|
|
|
I am currently looking for the highest quality, easiest to implement, most secure and most reliable peer to peer c++ package avaliable to implement peer to peer networking in c++.
The company I work for already has a very robust and complex program which operates under a client-server network architecture. I am exploring migrating that architecture to peer to peer.
I have so far come across what appear to be the three best packages avaliable online:
1) P2PToolkit - www.p2ptoolkit.com
2) Howl - http://www.swampwolf.com/products/
3) JXTA-C - http://jxta-c.jxta.org/servlets/ProjectHome
Obviously, there is always the option of coding it up ourselves and not using a pre-defined package but I estimate that would take more time and money than necessary.
We have done some initial testing of P2PToolkit sample programs and have found them to be extremely unstable and unreliable. Then again, those were just the sample programs given online. HOWL seems encouraging as it uses the Zeroconf "standard" adopted by Apple Computer, but there is a discouraging amount of documentation avaliable.
I am very excited by the JXTA program and we have other projects which have used it in java-implementations of peer to peer networking. JXTA-C would be a definite choice, especially in light of its claims of interoperability, except according to the JXTA-C program site, its not finished and has not had any kind of final release. In fact, according to the program site, the majority of the project hasn't been touched in at least a year, which implies forward progress stopped in some way.
Does anyone out there have any suggestions about any of the three aforementioned Peer to Peer packages, either from experience or knowledge? Has anyone worked on a large scale project involving peer to peer networking and could share their experience?
Thanks in advance.
-EEder
|
|
|
|
|
Well, it is really project specific. While "peer to peer" is a beautiful term, it can mean million different things. Judging by your java reference I assume you prefer RMI, in which case why don't you go with Corba (COM/ DCOM) or even RPC?
|
|
|
|
|
Actually, my Java reference was to a different, although similar, project. Although the potential of that project and my current one being able to easily operate together if need be (part of my reason for being excited about JXTA) is nice.
I did use the term 'peer-to-peer' loosely and thats becuase I think its a pretty standard 'peer-to-peer' application. I'm looking for -
1) Self realizing network - discovery of peers when they arrive on the network, although a nameserver may be necessary.
2) standard message sending, data transfer
3) security is a factor, although not a driving one
The project currently handles all the data transfer properly, it just does it between a client and server.
Thanks for the comments!
|
|
|
|
|
HI,Guys
I tried all methods I know,but it seems all the methods don't work?Could anyone help me?
YES, I am here.
|
|
|
|
|
float f =-89.567;
char * a = (char*)f;
|
|
|
|
|
thank you very much
YES, I am here.
|
|
|
|
|
That won't work at all.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
char buffer[100];
sprintf(buffer,"%f",floatvalue);
bb |~ bb
|
|
|
|
|
thank you.But it seems that must include the file stdio.h
YES, I am here.
|
|
|
|
|
When I look at the answers I see that both answers are completly different. The first casts the float to a char* so that you can look at the bits of how the processor encoded the float. I am not sure why you would want that.
[EDIT]
Also if you want that you should use BYTE or unsigned char instead.
[/EDIT]
The second returns a string that represents the float number. This is more likely what you want.
Which one are you looking for?
John
|
|
|
|
|
<br />
char* ConvertBSTR(BSTR text)<br />
{<br />
return (char*)_T(text);<br />
}<br />
I've got this function, but when I call:
<br />
char* temp;<br />
temp=ConvertBSTR(BSTRTEXT);<br />
MessageBox(NULL,temp,"",MB_OK);<br />
It only converts the first character
Does somebody know how to resolve this problem???
|
|
|
|
|
[edit] This solution won't work because the converted string is actually on the stack, so the returned string will be invalid. The macros will have to be used inline, not in separate functions [/edit]
You can't use a BSTR like that. A BSTR is a unicode string. To convert BSTR to a char* , use the ATL conversion macros:
[edit]You have to include "atlconv.h" first[/edit]
char *ConvertBSTR(BSTR text)
{
USES_CONVERSION;
return W2A(text);
} In your case, you only need a const char* , so you can do this
const char *ConvertBSTR(BSTR text)
{
USES_CONVERSION;
return W2CA(text);
} Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
No, still doesn't work
Any other options?
|
|
|
|
|