|
After looking at the MS sample ATL Server projects is it better to always
return S_OK from a method([web_method]) and pass back error information
through either an out paremeter or through a soap header?
Cheers
Ollie
|
|
|
|
|
Well, I guess yes, because if you will return something other then S_OK (like E_FAIL, whatever), the error can be intercepted before it will come to your code. Thus the result can be unknown, depending of the implemntation, maybe it will raise exception, maybe it will let it go..
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Well in my C# application that consumes the web services it raises a SOAP exception and there is no defining information in the exception that will tell me why it failed.
If I want to return rich error information from COM(i.e. IErrorInfo) then I am going to have to return this as either a parameter or a soap_header, but i do not want to specify an extra parameter in every method defined, so I am thinking of using a soap_header set as an out parameter.....
Any thoughts......
|
|
|
|
|
hi all
My program compiles ok but in run-time whenever i tried to access a function from the CListBox MFC class that is placed in a CDialog from View class, it gives me the above error. Does any one know why??
The sameple code is placed below
Dlg dialog;
CString temp[4];
for (int i = 0 ; i < 4; i++)
{
temp[i] = pDoc->A.getTeam(i);
}
dialog.SetTeam(temp);
if(dialog.DoModal()==IDOK)
{
curSelTeam1 = dialog.GetCurSelTeam1();
}
and here is my Dlg class
Dlg::Dlg(CWnd* pParent )
: CDialog(Dlg::IDD, pParent)
{
for(int i = 0; i< 4; i++)
{
team[i] = "";
}
}
const int Dlg::GetCurSelTeam1()
{
return m_team1.GetCurSel();
}
void Dlg::SetTeam(CString t[4])
{
for(int i = 0; i< 4; i++)
{
team[i] = t[i];
}
}
void Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST4, m_team2);
DDX_Control(pDX, IDC_LIST3, m_score2);
DDX_Control(pDX, IDC_LIST2, m_score1);
DDX_Control(pDX, IDC_LIST1, m_team1);
}
BEGIN_MESSAGE_MAP(Dlg, CDialog)
END_MESSAGE_MAP()
BOOL Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
for(int i = 0 ; i< 4; i++)
m_team1.AddString(team[i]);
for(int j = 0 ; j< 4; j++)
m_team2.AddString(team[j]);
for(int k = 48 ; k < 58; k++)
{
m_score1.AddString(CString(k));
}
for(int m = 48 ; m <58; m++)
{
m_score2.AddString(CString(m));
}
m_team1.SetCurSel(0);
m_team2.SetCurSel(0);
m_score1.SetCurSel(0);
m_score2.SetCurSel(0);
return TRUE;
}
Thanks for reading this everyone and hopefully you can enlighten me!
Source code of the program can be downloaed for further investigation at http://z3r0n3.hypermart.net/ass3_q1.exe
|
|
|
|
|
Once DoModal returns, the controls have been destroyed. You need to save the current control settings prior to the dialog closing.
Unfortunately, I hate DoDataExchange so I have no clue how to do it using that stuff.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
You are using Modal dialog. Any control is not exist after DoModal exits. So you should do it either modeless dialog or update some member value (like int or CString) in your dialog class in OnOK handler for example
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
thanks , i've override the On:OK method and saved everything to a temporary variable and get the value from this variable later on. Thanks heap.
Cheers
|
|
|
|
|
Version 2 of the question
While I've learned a lot of this page, still I do not know the following:
I've the code:
class hehheh
{
HWND somewhere;
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
void SomeFunction()
{
SetWindowLong(this->somewhere, GWL_WNDPROC, (LONG)WndProc);
}
}
which doesn't work (that I know, and I know why), but the solution of giving the
this as parameter can't be done, because there isn't room for it, how to work arround this problem.
I'm fighting with the code for several weeks already.
Thanks already
N.B. I'm not using MFC / WTL, and I just cut'n'paste some rules out of the code, so I gave it some other names for easyness.
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
Sorry, I misread the question.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
If you are trying to SetWindowLong and you want the HWND of "this" try..
SetWindowLong(this->GetSafeHwnd(), GWL_WNDPROC, (LONG)SubClassProc);
instead of the
this->somewhere
Hope this helps..
Rob
|
|
|
|
|
Where is the SubClassProc function defined, did you mean to put hehheh::WndProc as the function that you want to set in SetWindowLong?
If so you can make WndProc a static function of the class. Then when you create your window that the class represents, store a pointer to the class in the USER_DATA of the window by calling SetWindowLong(GWL_USERDATA, this);
Then inside of the static version of WndProc, get the USER_DATA variable and cast it to a hehheh pointer like this:
hehheh *obj = dynamic_cast<hehheh*>(::GetWindowLong(GWL_USERDATA));
if (NULL == obj)
{
}
With this pointer inside of your class you can call the real WNDProc of your class with the pointer that you just decoded.
If you really want to do it efficiently, look at how it is done in WTL's WndProcThunk class.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Now I'm coming to what I wanted. So the GWL_USERDATA contains this (the pointer to the class instance) and that I can call it back (Ah, now I understand why they called it CALLBACK ) via the obj, and obj is still the same pointer to the address of the class instance: this I guess?
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
SetWindowLong(this->somewhere, GWL_WNDPROC, (LONG)SubClassProc); I guess you meant this to read
SetWindowLong(this->somewhere, GWL_WNDPROC, (LONG)WndProc); Otherwise, I'm not catching your question.
I think this thread addreses your problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I wasn't really clear about what I wanted, but I'm not using MFC or WTL, so I think that has to clear bit's up. the HWND somewhere I declared is just an existing working HWND, but I just had to take a name.
The SubClassProc is indeed a failure, it has to bee WndProc instead.
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
Maybe you haven't noticed my previous post contained a link to another discussion where a solution is provided (In my browser the link appears almost unnoticeable.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am having problems with running this code twice..
I have a function that calls OnStartThread() after the thread has finished the work and the data has been updated I try to run this again and my program crashes. I think it has to do with the PostMessage (not sure though).. do I have to kill the msg after I post it? What am I doing wrong?
......
void run();
void OnStartThread();
volatile BOOL running;
static UINT run(LPVOID p);
......
void CMainFrame::OnStartThread()
{
running = TRUE;
UpdateData(FALSE);
AfxBeginThread(run, this);
}
UINT CMainFrame::run(LPVOID p)
{
CMainFrame * me = (CMainFrame *)p;
me->run();
return 0;
}
void CMainFrame::run()
{
.....
PostMessage(ID_UPDATE_TIME,0,0);
running = FALSE;
}
Thanks,
Rob
|
|
|
|
|
You are not doing it in thread. You sure have to use PostMessage to start a function in another thread. Look, CMainFrame belongs to one thread and when you are calling a function of it from another, the function is still running in same thread and context as CMainFrame
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
I'm not sure I fully understand.. If I start the worker thread from CMainFrame and I want to call a function inside CMainFrame I shouldn't use PostMessage? When I try to run the function with out posting the msg. it crashes because the function that gets called assigns and accesses a pointer to CListView..
The PostMessage seems to work only once.. If I try to run the worker thread again the app crashes at PostMessage?
Can you give me some more details so I can understand what I am doing wrong?
Thanks!
Rob
|
|
|
|
|
Omg... now I'm confused, lol. I saw that you have 2 functions with same name, one is static and one is not. But this is doesn't matter, you should not use pointer to CMainFrame in another thread to un functions, you should use PostMessage always to communicate between threads, then in the handler of that message (in CMainFrame) you can call any function of the frame.
So it goes like this:
CMainFrame (thread 1) -> [New thread] -> PostMessage to CMainFrame (thread 2) -> Handle message in CMainFrame (thread 1) -> call to run (thread 1)
You see? There is no direct access to CMainFrame functions from thread 2. Instead you are posting message, and it works like trigger, command to CMainFrame to start working with run
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
so with in run(LPVOID p) instead of passing a pointer to CMainFrame and executing run() I should PostMessage to CMainFrame to run the run()? Then with in run() I can post a msg back to CMainFrame to run the UpdateTime() function?
hehe how weird..
|
|
|
|
|
Errr.... lol, well it is because you have function names that are not suitable for such communication
But yes, this is the preffered way. Of course you can use Events, mutexes, semaphores and another such tricks, but PostMessage is the easiest one. The point is that you can't use a pointer (class, whatever) from another thread to run functions from the second
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Ah, well, discard my previos post. I just paid attention that your "run" function is static, which has same meaning as global. So you should not use the pointer to CMainFrame to reach it, but: CMainFrame::run()
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Does anyone know of a line drawing function where I can specify the degrees the line should be drawn (i.e. - 0 to 360 degrees). I am also looking for a function to export this line as an image and save it to a file. Any help would be great. Thanks.
Nick Parker
Actually, real programmers don't need the enter key- they just type in 00001101."
|
|
|
|
|
I believe you should be able to use just sine and cosine calculations to figure this out and use LineTo etc to draw the lines.
|
|
|
|
|
Is it the same way you do when exporting functions from a DLL when exporting a function from an EXE??
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|