|
All,
I posted a description of this problem on the following board, which the source code was available from:
http://www.codeproject.com/system/serial.asp
Because there is so much more activity on this board I thought I would also post a link to it here. Anyone familiar with the CSerialWnd class might be able to offer me some advice.
Thanks,
Robert
|
|
|
|
|
This article here:
http://www.codeproject.com/dialog/scrollablechilddialog.asp
is really cool, but it's for a CDialog. I am trying to
re-write it for a CFormView. The section of code here:
CRect rc;
GetDlgItem(IDC_PLACEHOLDER)->GetWindowRect(rc);
ScreenToClient(&rc);
m_pdlgScroll->MoveWindow(rc);
I have a CFormView with the resource IDD_FORM1. How
can I rewrite this section of code properly? I can't
have:
GetDlgItem(IDD_FORM1)->GetWindowRect(rc);
?????
|
|
|
|
|
I have been working on a project that retrieves various credit reports from the 3 credit bureaus. I have been trying to retrieve the certificate that I am getting back when connecting to the bureau so that I may verify the certificate. All the examples I have found in the Microsoft documentation show me how to retrieve the info from my local machine but not from the server.
I found information on winhttp and downloaded the latest Platform SDK to utilize it. I created a class to use winhttp to get the certificate back and verify it. The class compiles fine, but when I compile the complete application I get LNK2001 ConvertStringToBSTR errors. When I uninstall the SDK I can compile the application again without using the new class.
I am using Visual Studio .NET (not 2003).
Might anyone know how to get around this or a way I can accomplish the same thing without using winhttp?
|
|
|
|
|
|
I saw comsupp.lib as well, but I still get the same LNK errors linking with comsupp.lib.
I guess I will keep looking for alternatives. Thank you for your input.
|
|
|
|
|
I’m Visual C++ newbie trying to make a Win-32 class that create a hover button (without MFC).
I trying to use the mellertson's article "How to use SetTimer() with callback to a non-static member function" to substitute button’s WNDPROC, so it can process it's own WM_MOUSEOVER, WM_MOUSEHOVER, WM_MOUSELEAVE messages.
I use all the technique shown in the article, and work fine, but only with one control. If I create two o more controls, pObject always refers to the last control created.
Anybody knows how to call a callback function within it's own class?
Please help me.
|
|
|
|
|
The most easiest approach to this problem is not by following Mellertson's article.
Like you stated, you are creating a class that manages a custom button control. What you are doing, infact, is much similar to MFC: a wrapper class for a Win32 API routine. MFC, although, implements everything based on the window-thinking: every control is derived from CWnd.
Instead of using Mellertson's article, consider the following approach:
1. In your program, create a new instance of the class. When this instance is created, all member functions and variables of the class become valid.
2. Call a 'second-phase' constructor that creates the actual Windows button control. As all member functions are properly initialized in step 1, you can refer to a non-static member function to handle the WNDPROC's job.
This approach allows each instance of the button class to function independently, ESPECIALLY if you use dynamic creation of the objects. Just remember that the clean-up work must be implemented very carefully to avoid memory leaks.
In the 'second-phase' constructor, you can use the Win32 API routines to create the button control, and the returned HWND to replace the window procedure function.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Let's see, I understand two different things:
1. I create a class A , with my non-static callback function (WndProc ) and other members. Then I made class B derived from A , in which I create the button and refer to ::WndProc as my new callback function. Or,
2. I create a class A with two constructors. The first one initializes my WndProc and other members. The second one create the button and replace the window procedure function to WndProc .
Which way I should take?
I still confuse
|
|
|
|
|
The option number two is correct.
However, I wouldn't recommend replacing the original window procedure. Instead, register a new window class, call it "MyButton", for example. Implement a handler for WM_PAINT, then use DrawEdge SDK function to draw the button edges and place the text on the button. This allows a much greater degree of control on how the button looks and behaves.
I suggest this method mainly because if you replace the original procedure, you must restore it as well when a WM_DESTROY message comes, otherwise the button control might not get freed properly, thus resulting a memory leak.
Here is an article I found while surfing the web. It gives you a basic idea on how to implement an MFC-style window class wrapper. Basically, it has a window procedure method as a non-static function, then it has a static message router function, which is passed to the window class registration. The router, on the other hand, is able to get the correct instance of the class from the passed variables (WPARAM and LPARAM) and then call the appropriate message handler. This behaviour is required if you create multiple objects from the same class.
The article itself can be found here[^].
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Oh man it's too much for me, but I'll try it.
Thanks a lot!
|
|
|
|
|
I'm new to MFC and I created a SDI application. Now I added a new form and the based class is CFromView. Everytime I compile the project, I get a little pop-up window which is asking me to choose which form to load. How can I set one of the form as a default and I would like to add a button on the main to call the second form. Like we do in VB.
Thanks...
|
|
|
|
|
iboux wrote:
Everytime I compile the project, I get a little pop-up window which is asking me to choose which form to load.
The compiler is asking you this, or your application?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi,
I'm creating a program that uses threads. The question is should I use the WinAPI CreateThread or the CRT _beginthreadex?
I know the MFC CWinThread, but I don't want to use MFC for this project, so I have only 2 chances.
I'll post some code and comment out why I ask you this decission.
I have a class, and I want to launch a member function as a thread, so I use this launcher function:
DWORD WINAPI ReceiveThreadProcStub(LPVOID pObj)
{
((CClass1*)pObj)->Receive(pObj);
ExitThread(0);
}
To launch the thread I use:
void CClass1::Func1()
{
.....
hReceiveThread = CreateThread(NULL,0,ReceiveThreadProcStub,this,0,&nReceiveThreadId);
....
}
So I pass the parameter "this" in order to execute the CClass1::Receive() function in a new thread. I use some CRT functions, and I have readed that using "CreateThread" may cause memleaks with CRT. But I don't know if in this case there should be memleaks, as the function I'm running in the new thread is a member of a class, so maybe this could prevent memleaks on the object destruction.
That's my question.
P.S.: Is there any method for forcing a thread to terminate (from the outside of the thread) without using "TerminateThread"?
Thanks
|
|
|
|
|
I strongly recommend using boost::thread, which internally uses _beginthreadex. Personally while I've been learning about threading I've spent more time worring more about the higher level details rather than about specific API calls.
Boost::thread prevents many of the common problems - for instance it guarantees that the thread is running before the constructor finishes, as well as providing a variety of lock mechanisms and providing a general way to pass in any function with any signature.
It also provides a way to ensure that a thread will finish.
http://www.boost.org/[^]
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
that depends on the question if you use CRT code in your new thread.
the only difference between _beginthreadex and CreateThread is that CRT allocated per-thread data when using _beginthreadex.
have a look at "threadex.c" for further details.
(I don't use _beginthreadex, because I don't use CRT, I've written all functions myself so I don't need CRT.)
Don't try it, just do it!
|
|
|
|
|
I am writing a plug-in, which is a DLL (not exporting MFC classes). My dll exports a function, when it is called I show the MFC dialog window. Like this (I have an application class to support mfc, created by wizard):
void my_func()
{
CMyDlg dlg;
dlg.ShowModal();
}
This works. I have a problem, when I am trying to use Frame based window. I have a SDI frame and I can show it. But when I was closing it I have an exception in CFrameWnd::OnClose(), because this function closes the document and then tries to access it. I overrided CMainFrame::OnClose(), so it solved the problem (I just hide my frame). But when the host application terminates I have an access violation at CThreadSlotData::GetThreadValue(int nSlot) function at this line:
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
Anybody knows why should this happen? Maybe my dll tries to process some message, which it shouldn't? Any suggestions? Host application calls another exproted function from my dll, before exiting, but this function is not called, so I wonder how does my dll knows about termination, before host application infroms it about it?
Thanks in advance.
Regards,
Alexander.
|
|
|
|
|
Dear all Members,
Luckily, I found this site on the net. I knew you are the professonal VC programmers.Help me please.
I used MFC to make my program(related to image processing). There were some questions I would like to ask you:
1.How to display and modify the R,G,B value of a loaded image?
2.I have a 24bit bmp image.How to display the Rimage, Gimage and Bimage??(that's mean on the screen there are 4 images:RGBimage,Rimage,Gimage and Bimage).
3. How to display the R,G,and B histogram?
THank you in advance!!
Best regards,
Mr.Tran.
Mr.Tran
|
|
|
|
|
You can look at following places:
http://ece.unh.edu/svpal/Users/shyrokov/index.html
it has source code available. You can see how to load image and how to display, though it does not work with 24 bit images, it could help you. It also has routins for histogram calculation.
http://www.intel.com/research/mrl/research/opencv/
Is a special library dedicated to image processing and you can find it very useful.
Also have a look at libraries like:
http://freeimage.sourceforge.net/
http://corona.sourceforge.net/
Good-luck.
Regards,
Alexander.
|
|
|
|
|
|
I've (finally) decided to join the 20th century and switch to VC7.
Does anyone know how to permanently (i.e. globally) turn off code outlining. I know you can R-click a source file and toggle it, but I was hoping to find a global setting. Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Toosl->Options->Text Editor->[Language]->Formatting
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
|
ahhhhhhhhhhhhhhhhhhhh ravi
there are sooooooooo many more horrors waiting to jump u
i HATE the ide of vs.net for c++ coding
"there is no spoon" biz stuff about me
|
|
|
|
|
I can imagine...
I spent (wasted) several minutes fighting VC7's desire to tabify my windows in ways that can only be described as unholy. And why did they do away (i.e. change) Alt-F3? I've got the IDE to (sorta) resemble my old favorite, but I'm sure I'll run into more problems once I start using the thing to real work.
Oh, and an attempt to convert a VC6 DLL (that uses a lot of STL) caused it to complain that it couldn't find "iostream.h" (it should be in my #include path), and a few seconds later, crashed my W2K box. First crash in years!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
yah
it really is a huge step forward in productivity tools
NOT!
wait til u try and find class wizard
"there is no spoon" biz stuff about me
|
|
|
|