|
Actually on the button click of the Parent dialog i want to fetch data fom the server and show it on a child dialog and at the same time i am using an animation control to show the status of loading or processing.
Earlier I was doing it as a single process so the animation control was not working while data was coming and being painted on the child window rather it was working after the data was already fetched and painted.
For that reason i have created a new thread and paled the code for animation in it but i dont knowhot to ruun a thread. I have used the following code.
void CMainDlg::OnDetails()
{
running = TRUE;
CWinThread * myWorkerThread;
myWorkerThread=AfxBeginThread(run, this);
if(IsGetDlg_created==true && m_dlgGetFootPrint.IsWindowEnabled()==true)
{
UpdateSelectedVisitorDetails();
m_dlgVisitorDetails.ShowWindow(SW_SHOW);
m_dlgGetFootPrint.ShowWindow(SW_HIDE);//added by dhiraj on 27-08-08
//m_dlgGetFootPrint.DestroyWindow();//added by dhiraj on 28-08-08
}
else
{
UpdateSelectedVisitorDetails();
}
}
//added on 6-09-08
UINT CMainDlg::run(LPVOID p)
{
CMainDlg * me = (CMainDlg *)p;
me->run();
return 0;
}
void CMainDlg::run()
{
m_avi.Open(IDR_AVI1);
m_avi.Play(0,-1,-1);
running = FALSE;
}
Whats wrong in it.
|
|
|
|
|
One remark: please read the posting guidelines before posting a new message. Format your code properly so that it is easier to read (didn't some people already tell you that ?)
For your question: you are doing the opposite as you should: your thread should be used to fetch the data from the server, not to do some UI stuff. All the UI stuff (e.g. playing the animation) should be done in the main thread. So, in your thread function you should put all the code that is trying to fetch data from the server, and send messages to the main thread to inform the UI about the status of the operation.
|
|
|
|
|
If I use the dc returned by CPrintDialog::GetPrinterDC to do print, will there be problems(eg. print pool)?
system
|
|
|
|
|
I don't see any issues in using the Printer DC returned by GetPrinterDC Method.
Regards,
Rane
|
|
|
|
|
I was wondering if anyone knew of a straight forward way of calling (non-exported) functions in an executable from a DLL. We are building a, for lack of a better name, private plug-in system that will grant the plug-in access to all of a processes internals, without having to export the hundreds of methods and classes we have.
cheers,
-B
|
|
|
|
|
oohhh .. thats a hard one. Unless your executable exposes some sort of API I think you'd have to resort to using injection/hooking from the dll (which I presume is in another process) to access the functions in the executable, even then ...
Usually as Im sure you're painfully aware, a plugin system involves the executable 'discovering' its plugins, then possibly calling something within the plugin to say 'what do you expose/do', or has a narrowly defined interface, not the other way around ..
If it were me (and Ive been here before, and are about to venture in this space again), I would would have the exe expose its functions through an IPC or TCP/IP interface, presenting commands to a command interpreter built into the exe, but its hard to do that unless you build it from the ground up. My next app is going to have an inbuild mini-webserver in it for both input/output and control ..
Maybe you can research injection/hooking, the microsoft library 'detours' for example to see if that can help ... the danger with these (well, one of the dangers), is that the usage is tightly bound to your internals/classes ...
sorry, good luck
[edit] .. if it were just a matter of exposing global variables for instance, I'd be using a shared memory implementation [/edit]
'g'
|
|
|
|
|
Thanks, I figured it'd be a tough one... just thought I'd ask
One option I was already looking at was generating a map of all the function addresses and giving plug-in builders a stub to link with that would find the location of the function in the loaded executable, properly construct the stack for its calling convention, and then call it. Very harry.
As for the API idea: we were planning on exporting a simple and well defined API for public plug-ins, but we would like to have private plug-ins have first-class access to all the symbols in the running process, which is the problem area. As for shared memory, I'd love to do that too, but it would require some time to track down all the globals we export, and I'm not sure I'm up to spending the next few days (years?) tolling though 20+ years of code to find all the interdependencies. So, although it's a great suggestion, I think this part needs to be automated, to be done at build time, such that any new globals will automatically be exported/shared. Also, I've little faith that the Linux/UNIX developers would appreciate me making them add extra dressing to their globals (and even if they loved the idea, if someone forgets once just before a release, then our users are out of luck if they want to access that object).
I think we'll just scrap the idea of "private" plug-ins for now, and just define a basic public API. We already support SOAP, among other network based communications channels, so we may just expand the SOAP interface to allow for a greater range of hackery.
Thanks for the input.
cheers,
-B
|
|
|
|
|
Hi.
I am creating a MFC DLL using MFC as statically linked. It is basically a dialog based app, except I'm creating it as a DLL.
I am doing this in Studio 2005.
It has one dialog, with Ok,Cancel buttons and one CEdit box.
When I try to use AfxMessageBox( ),
AfxMessageBox("I am about to create/instantiate MyLilDllDlg dialog", MB_ICONWARNING, NULL);
I get compiler error as follows:
1>c:\temp\dll\mylildll\mylildll\mylildlldlg.cpp(40) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5031): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5033): or 'int AfxMessageBox(UINT,UINT,UINT)'
1> while trying to match the argument list '(const char [52], long, int)'
Is there something I need to include or configure in my project settings to allow me to use Afx... ?
Thank you.
|
|
|
|
|
The third argument must be 0, not NULL, to make it a UINT value. The compiler error returned means that none of the two overloaded argument types (either LPCTSTR, UINT, UINT or UINT, UINT, UINT ) were found in your execution of the AfxMessageBox() function as NULL is not a legal UINT value.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
First off, thanks! Embarrasedly I should have looked closer at what the suggestion in the compiler was saying.
I settled on the following:
AfxMessageBox(LPCTSTR("I am about to create/instantiate MyLilDllDlg dialog"), MB_ICONWARNING, 0);
It needs the casting to LPCTSTR. I got by with last arg being NULL.
Thanks for telling me what I was doing wrong. Without that, I would have not tried to find out more about it on my own.
Johnny
|
|
|
|
|
hi,
I'm just a beginner at programming(c++) and I wanted to create a program to do binomial expansions easily,
I have created the program and it works well. But because i'm a beginner at programming i'm using a win32 console for the program and i want to show powers, squares and cubes, which in the output of my program look like this:
2^3
0r
4^2
is there any way to show them as you would write them, like in superscript or something cos at the moment it looks a mess.
Hope you understand my problem.
Any answers appreciated
ps if you have any recomendations on C++ books which include how to use windows forms to create a program they would be appreciated
|
|
|
|
|
toprogramminguy wrote: is there any way to show them as you would write them, like in superscript...
Yes, but the exponent would be a whole line above the base.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
exponents of 2 and 3 have their own symbols in unicode. You will have to stick with x^4 for exponents of 4 (and 5, etc), but they're definitely there for 2 and 3. You will need to compile for unicode in order to use these characters. You can compile for Unicode by defining the symbols UNICODE and _UNICODE in your compiler definitions.
If you go into character map and search for "superscript" then you will get 5 results, four of which may be helpful to you. Those are the characters you need to use.
http://img122.imageshack.us/my.php?image=superscriptja8.jpg[^]
|
|
|
|
|
Hey.Guys!
I've been puzzled by this kind problem these days while doing with CTreeCtrl. My target is going to Dynamically insert any number of child items into an Empty Item by clicking + button. To do that,i have to force the control to display the + even though the item does not have any child items inserted.
i followed the instructions from msdn by setting cChildren of TVITEM struct to I_CHILDRENCALLBACK since the ctreectrl has the TVS_HASBUTTONS style. then handle with TVN_GETDISPINFO notification message. but that does not work anyway:
void CMutiTreeCtrl::OnTvnGetdispinfo(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVDISPINFO pTVDispInfo = reinterpret_cast <lpnmtvdispinfo>(pNMHDR);
if((pTVDispInfo->item.mask & TVIF_CHILDREN ) == 0)
{
HTREEITEM hSelected = GetSelectedItem();
TV_INSERTSTRUCT tvinsert;
tvinsert.hParent=hSelected;
tvinsert.hInsertAfter=TVI_LAST;
tvinsert.item.mask=TVIF_TEXT;
tvinsert.item.hItem=NULL;
tvinsert.item.cchTextMax=50;
tvinsert.item.lParam=0;
tvinsert.item.pszText=_T("inserting child items only when the item is visible or expanded");
*pResult = 1;
}
else *pResult =0;
}
Is there any problem with the code?Any suggestion?Thanks
HALLELUJAH! Hallelujah! Hallelujah! Hallelujah!
|
|
|
|
|
KmLee David wrote: My target is going to Dynamically insert any number of child items into an Empty Item by clicking + button.
Rather than clicking the item itself?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
just insert child items while expanding the empty item to display these child items, maybe double click the item or click the + .any way u wish.
the most important thing is how to handle with the TVN_DISPINFO notify message to achieve my purpose
HALLELUJAH! Hallelujah! Hallelujah! Hallelujah!
|
|
|
|
|
KmLee David wrote: Is there any problem with the code?
Yes.
TVN_GETDISPINFO
"Requests that a tree-view control's parent window
provide information needed to display or sort an item."
You shouldn't be inserting items in response to this notification.
You also shouldn't be calling GetSelectedItem().
The TVN_ITEMEXPANDING notification is maybe a better place to insert
the child items.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: TVN_GETDISPINFO
"Requests that a tree-view control's parent window
provide information needed to display or sort an item."
You shouldn't be inserting items in response to this notification.
You also shouldn't be calling GetSelectedItem().
The TVN_ITEMEXPANDING notification is maybe a better place to insert
the child items.
Thanks a lot,finally i've figure out the problem. Here is my solution
void CMutiTreeCtrl::PopulateTree()
{
TV_INSERTSTRUCT itInsert = {0};
CString strText;
strText = _T("Start");
itInsert.item.pszText = const_cast<LPTSTR>((LPCTSTR)strText);
itInsert.item.state = TVIS_BOLD;
itInsert.item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_TEXT |
TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
itInsert.item.stateMask = TVIS_BOLD | TVIS_STATEIMAGEMASK;
itInsert.item.cChildren = I_CHILDRENCALLBACK;
itInsert.hParent = hRoot;
HTREEITEM hItem = this->InsertItem(&itInsert);
UpdateWindow();
}
void CMutiTreeCtrl::OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)
{
CWaitCursor curWait;
SetRedraw(FALSE);
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
HTREEITEM hItem = pNMTreeView->itemNew.hItem;
HTREEITEM hRemove = this->GetChildItem(hItem);
while(hRemove)
{
ctlTree.DeleteItem(hRemove);
hRemove = this->GetChildItem(hItem);
}
CString strText = _T("This is the Child Item which is dynamiclly inserted");
AddMySubItems(hItem, strText);
SetRedraw(TRUE);
Invalidate();
*pResult = 0;
}
void CMutiTreeCtrl::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult)
{
TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
pTVDispInfo->item.cChildren = 1;
*pResult = 0;
}
HALLELUJAH! Hallelujah! Hallelujah! Hallelujah!
|
|
|
|
|
Hello,
I am writing a BlackJack type program to learn C++/.NET. I'm, trying to raise an event from Shoe Class (DealtCutCard Event) which is used by Dealer Class. Dealer sets a flag and at the apprpriate time raises a DealerShuffles Event which the Shoe Class uses.
This code won't compile, the error is in the Shoe.h:
"improper syntax for specifying event in __hook/__unhook" line 25
"improper syntax for specifying event in __hook/__unhook" line 25
"improper syntax for specifying event in __hook/__unhook" line 25
If I comment out #include "Dealer.h" and the __hook init function this will compile, but now I can only raise events from Shoe it won't recieve events from Dealer.
How can I both call and handle events from between the same two classes?
BTW - note i NEED "Shoe.h" in Dealer because there are functions in Dealer that reference Shoes.
Using .NET 2003
Also, I tried substituting #include "Dealer.h" with class Dealer; as a predeclaration but that didn't work.
Dealer.h
#pragma once
#include "Bettor.h"
#include "Hand.h"
#include "Shoe.h"
#ifndef DEALER_H
# define DEALER_H
[event_source(native)]
[event_receiver(native)]
class Dealer
{
public:
__event void DealerShuffles(void);
Dealer(Shoe*);
void InitShoeEvents(Shoe* pSource){
__hook(&Shoe::DealtCutCard, pSource, &Dealer::ReadyToDeal);};
};
#endif
Shoe.h
#pragma once
#ifndef SHOE_H
# define SHOE_H
#include "Dealer.h"
[event_receiver(native)]
[event_source(native)]
class Shoe
{
public:
void Shuffle(void);
void InitDealEvents(Dealer* pSource){
__hook(&Dealer::DealerShuffles, pSource, &Shoe::Shuffle);};
__event void DealtCutCard(void);
};
#endif
|
|
|
|
|
I'm currently coding a server and accepting incoming connections using the CAsyncSocket class under Vista.
Things are working fine but now I would like to be able to resolve the dotted IP address CAsyncSocket::GetPeerName() returns into a nice human readable name so users can easily identify connections rather than remembering strings of numbers (dotted ip's). Can someone point me to the API which will help me do that. Spent a while searching but everything talks about going the other way, that is name->dotted ip, not dotted ip->name.
Thanks!
|
|
|
|
|
jbem wrote: ...I would like to be able to resolve the dotted IP address CAsyncSocket::GetPeerName() returns into a nice human readable name...
Which of the two GetPeerName() methods are you using? Have you tried gethostbyaddr() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks I missed the gethostbyaddr(). I used getnameinfo() since gethostbyaddr is deprecated and it worked out fine. Thanks for your help!
|
|
|
|
|
hi to all
i want to store some string datas in a CString or similar variable
and i need a int variable also
this is a global hook dll and i want to update this variables at runtime
and all applications should access to this variables which load this dll
simly : i can say this dll will be a bridge between applications
which load this dll
i have found the following sample but i could not
write a working one from it
application exits with crash always
note: the following sample copied from a C project
and my dll is a MFC/C++ dll
thank you
#pragma data_seg(".shared")
#pragma comment(linker, "/section:.shared,rws")
HHOOK g_hHook = 0;
HWND g_hwndNotify = 0;
BOOL g_FirstInstance = FALSE;
UINT g_nButtonCmdId[MAX_TITLE_BUTTONS] = { 0 };
UINT g_nButtonResId[MAX_TITLE_BUTTONS] = { 0 };
int g_nButtonCount = 0;
WCHAR g_szBlackList[MAX_BLACKLIST][64] = { 1 };
LONG g_nBlackListLen = 0;
#pragma data_seg()
|
|
|
|
|
I have code which worked under VC6 and now failing under VS2005 (additional change was moving portions to a dll from a lib, but pretty sure this not affecting things)
I have an out-of-process COM server, which constructs a CWnd in the constructor of the CComCoClass templated object. The intent is for this CWnd to receive messages posted from a thread (created in a linked dll) to track external state. (why is it a CWnd? because the primary recipient of the dll's state messages is a windows app)
The CWnd seems to construct fine, but the thread goes quiescent. I don't think that the thread has a message loop.
Question: how to I get the CWnd into a messagepump? a) Can I change the CWnd creation? b) Can I force the linkage of the Cwnd into the PreTranslate tree? c) Do I have to punt the CWnd and go to a GUI thread (which seems to be effectively duplicating much of what just creating a CWnd should do for me, and forces me to add to the dll a parallel notification list)?
Messages sent from the posting dll thread can be received at the COM object's message loop (via PostThreadMessage), so I'm confident the switch from VC6 to VS2005 is the culprit not the change from LIB to DLL, especially since PostMessage works in the primary application.
class ATL_NO_VTABLE CServer:
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<cserver,>,
public IDispatchImpl<iserver,>
{
...
class wndHook : public CWnd{
public:
wndHook(){}
afx_msg LPARAM Message(WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
}*pWnd;
}
CServer::CServer(){
...
pWnd = new wndHook();
if (!pWnd->CreateEx(0, NULL, _T("HOOK"), WS_CHILD,
CRect(0,0,0,0), CWnd::GetDesktopWindow(), 0, NULL)){
TRACE0("Failed to create hook window\n");
}
GetDLL()->AddToNotificationList(ENUM_VAL, pWnd);
}
BEGIN_MESSAGE_MAP(CServer::wndHook, CWnd)
ON_MESSAGE(WM_APP, CServer::wndHook::Message)
END_MESSAGE_MAP()
void DLL::Post(WORD mID, long val)
{
...
::PostMessage([element in list]->GetSafeHwnd(), WM_APP, mID, val);
}</ccomsinglethreadmodel>
|
|
|
|
|
|