|
sorry ravi, it was a scoping issue but i am still not clear why. the CBitmap bmp; is required to be a class level member. I was assuming that when we call a setbitmap on the button and pass a HBITMAP to it, a copy should be sent and there should be no scoping issue.
|
|
|
|
|
I'm fairly new to MFC and have been tasked with migrating an app from VC++ 6.0 to VC++ 7.0 (vs.net). For those who have done this before, are there any things I should watch out for or know beforehand ?
I was simply going to create a new solution in VS.NET, import my VS6.0 projects into it, and then fix each thing the compiler complains about. Is this the right way to go about it ?
thanks in advance
|
|
|
|
|
I don't think that there is a 'right' way to a v6 to v7 migration. Each project likely has it's own dependancies, libraries, etc. Having said that though, your stated approach would certainly be a good starting point. Although I'd be tempted to have VS7 even create all this stuff for you, by having it open the VS6 project files and see what it does.
Chris Meech
I am Canadian. [heard in a local bar]
Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
what I noticed when doing this (VC++6.0 -> 7.0 - 7.2, Studio.NET) was I got a lot of errors with STDIO (generally speaking, and specifically statements that std::ofstream and std::ifstream).
I had a lot of instances where it was ok in 6.0, but when I tried to use IO calls, it needed me to change things to pointers in 7.0 (addresses needed).
my 2 cents...
Johnny
|
|
|
|
|
dvolpe wrote:
was simply going to create a new solution in VS.NET, import my VS6.0 projects into it, and then fix each thing the compiler complains about. Is this the right way to go about it ?
You should be able to just open your existing .dsw in VS7 and it will create the solution for you.
File -> Open Project and then navigate to your .dsw. Maybe take a copy of the 6.0 project folder first before doing it.
I would imagine that you should at least run into some issues with stricter C++ language conformance. So you may have to do a few tweaks. I've not tried it but I can't imagine there will be any major problems.
Kevin
|
|
|
|
|
Hello,
how to install (use) Shockwave Flash ActiveX component and work with him in MS VC++ 6.0 project (fscommand, getVariable, setVariable)?
Thanks!
Serg
|
|
|
|
|
I want to attach a CEdit to A CView,how can i do that,thanks.
just now i've tried another method, i creat a CEditView and use CEditView::GetEditCtrl,which return a reference of CEdit&,but i cannot replace the Standard CEdit to the special CMyEdit derived from that.
help,either way is ok for me now,thanks....
Josephvan thanks for your attention
|
|
|
|
|
CFormView is the only way I know how to do that. That makes it look more like a dialog though, so might not be what you are looking for.
|
|
|
|
|
You can add a CEdit to a CView-derived class (call it CMyView) easily.
In the MyView.h file, add a CEdit member varaible (call it m_ctlEdit).
In the MyView.cpp file, add message handlers for WM_CREATE (i.e., OnCreate) and WM_SIZE (i.e., OnSize). Add code like this:
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct) <br />
{<br />
if (CView::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
<br />
if ( !m_ctlEdit.Create( dwStyle, CRect(1,2,3,4), this, 0x1245 ) )<br />
{<br />
return -1;<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
<br />
void CMyView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CView::OnSize(nType, cx, cy);<br />
<br />
CRect rc;<br />
<br />
GetClientRect( &rc );<br />
<br />
m_ctlEdit.SetWindowPos( this, 0, 0, rc.Width(), rc.Height(), SWP_NOZORDER );<br />
}
This will fill the view with the edit, which might not be what you want, but it's easy to adjust.
Mike
|
|
|
|
|
hi, i am a student and im currently dealing with c++ programming base assignment. however, im not strong in c++ programming language. hope to get help and assiatance. here's my question:
i suppose to write a program that open the serial comm port, configure it and receive data from it. however, the program i wrote is not functioning as it suppose to, as in, it never receives any data. what is wrong with the code. hope to get help. besides, was wondering if anyone has any recommended code that works for me to refer. was really hoping to get help.
the code goes like thia:
#include <windows.h>
#include <stdio.h>
#include <iostream.h>
int main(int argc, char *argv[])
{
DCB cofiguration;
HANDLE hCom;
BOOL fSuccess;
char *pcCommPort = "COM1";
hCom = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, //share mode: off
NULL,
OPEN_EXISTING, //to open existing file such as port
0,
NULL
);
if (hCom == INVALID_HANDLE_VALUE)
{
cout<<"create file with error ";
cout<<getlasterror(); to="" check="" if="" the="" port="" is="" available
="" return="" (0);
="" }
=""
="" fsuccess="GetCommState(hCom," &cofiguration);
="" cofiguration.baudrate="CBR_9600;"
="" cofiguration.bytesize="8;" cofiguration.parity="NOPARITY;" cofiguration.stopbits="ONESTOPBIT;"
="" &cofiguration);
="" (!fsuccess)="" {
="" cout<<"error="" occur="" "<<endl;
="" cout<<getlasterror();
="" (3);
="" cout<<"port="" opened="" bool="" rdfile;
="" char="" *bufferofdata="" ;
="" unsigned="" long="" nbytesread;
="" int="" sizebuffer="100;
" commtimeouts="" ctmonew="{0}," ctmoold;
="" getcommtimeouts(hcom,&ctmoold);
="" ctmonew.readtotaltimeoutconstant="100;
" ctmonew.readtotaltimeoutmultiplier="0;
" setcommtimeouts(hcom,="" &ctmonew);
="" rdfile="ReadFile(" hcom,bufferofdata,="" sizebuffer,="" &nbytesread,="" null)="" ;="" (="" nbytesread="">0)
{
cout<<"the received word is: ";
}
else if (nBytesRead == 0)
{
cout<<"no input"<
|
|
|
|
|
There is a search bar near the top of this web page. Why not use it and search this site's articles for 'serial port' There are SEVERAL samples already how to open a serial port and read data from it on Windows
|
|
|
|
|
ya, i tried that and i got a sample code that works. but the thing is that the code is way beyond my understanding. i have no idea how it works. besides, someone has tried the code and it works according to him. but i tried with several method and i did not get any positive result. was wondering if there is anyone mind to let me know how do i try the program. thanks a lot. by the way, i'm using Visual C++ 6.
thanks in advance
Rgds
thwan
|
|
|
|
|
Hi all,
Instead of creting the buttons if i drag and drog the buttons and make them ownerdraw on the dialog box and and try to sendthe messages to the background applications the sequence in which the keystroke generate shold be WM_KEYDOWN ->WM_CHAR->WM_KEYUP but its coming as WM_KEYDOWN->WM_KEYUP-> WM_CHAR for me for the following code can any one help me
void MyDialog::GenerateKeyStroke(UINT nVirtualKeyCode)
{
CMainWindow *pView= (CMainWindow*)GetParent();
LPARAM lParam;
lParam = MapVirtualKey(nVirtualKeyCode, 0) ;
//scan code are from 16-23 in lparam
lParam <<= 16;
//since repeat count is one
lParam++;
pView->PostMessage(WM_KEYDOWN , nVirtualKeyCode , lParam ) ;
lParam |= 0xC0000000;
Sleep(0);
pView->PostMessage(WM_KEYUP , nVirtualKeyCode , lParam ) ;
}
and I shold use only PostMessage can any one help adn if press Alt key System keyevents should generate for me what should i do for that
Request to all to continue this
|
|
|
|
|
Does anybody knows how to use dwLastChange field ?
I would like to calc how long my network interface is connected.
Tks
|
|
|
|
|
adriano_alvarez wrote:
Does anybody knows how to use dwLastChange field ?
I believe that member represents the amount of time, in centiseconds, that has elapsed since 1-January-1601.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have installed Platform SDK Windows Server 2003 (I work in VS 6.0 on WinXP) and I have a problem with CFileDialog.
This code
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog dlg(TRUE);<br />
dlg.DoModal();<br />
}<br />
worked just fine before defining _WIN32_WINNT, which I need to use different functions and constants. Now, when I define it
<br />
#ifndef _WIN32_WINNT<br />
#define _WIN32_WINNT 0x0501 // can be 0x0500 as well<br />
#endif<br />
my code just crashes in ~CFileDialog (when dlg does out of scope and is destroyed). Since m_ofn member of CFileDialog depends on this _WIN32_WINT:
<br />
typedef struct tagOFN { <br />
#if (_WIN32_WINNT >= 0x0500)<br />
void * pvReserved;<br />
DWORD dwReserved;<br />
DWORD FlagsEx;<br />
#endif // (_WIN32_WINNT >= 0x0500)<br />
} OPENFILENAME<br />
I rewrote the code this way:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog dlg(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
dlg.DoModal();
}<br />
but I still get a first-chance exception in FileTest.Exe (KERNEL32.dll) 0xC0000005: Access Violation (the usual stuff).
Now, I found out that if I declare dlg dinamically it doesn't crash:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CFileDialog* dlg = new CFileDialog*(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
delete dlg;
}<br />
But If I derive CFileDialog to CMyFileDialog the program still crashes at delete:
<br />
void CFileTestView::OnViewFile() <br />
{<br />
CMyFileDialog* dlg = new CMyFileDialog*(TRUE);<br />
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
dlg.m_ofn.pvReserved = NULL;<br />
dlg.m_ofn.dwReserved = 0;<br />
dlg.m_ofn.FlagsEx = 0;<br />
#endif<br />
<br />
delete dlg;
}<br />
Any ideas? Thanks!
|
|
|
|
|
Does the problem persist if you use GetOpenFileName() instead?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Here's an idea...
Look at the beginning of the class definition for CFileDialog...
class CFileDialog : public CCommonDialog
{
DECLARE_DYNAMIC(CFileDialog)
public:
// Attributes
OPENFILENAME m_ofn; // open file parameter block
Whoa! There's an OPENFILENAME m_ofn member variable, and YOU DO NOT CONTROL IT'S SIZE!
You would have to rebuild your MFC DLL or rebuild the static MFC library to which you are linking, using the NEW size. Anyway, that is why you get the crash - you write to data that overwrites something else!
If you really need these new fields, you are going to have to 'swipe' the CFileDialog source code and make your own using the new data structure. Otherwise, just use OpenFileName as David Crow suggests.
|
|
|
|
|
First, my project is too large and I don't want to go and replace everything with OpenFileName().
Second, when I have to define _WIN32_WINNT to 0x0501 because I need it to use other functions that are define like
<br />
#if (_WIN32_WINNT >= 0x0500)<br />
#endif<br />
so OPENFILENAME will have the extra three data members. If Platform SDK provides me this (actually) new structure doesn't it also provide the necessary lib? Because of my settings it should try to link first to SDK libs and only after (if not found) to VS6.0 old libs.
|
|
|
|
|
does anyone know how to communicate with the Windows MIDI driver thru USB.???
|
|
|
|
|
Hello,
I am developing a DLL on eVC++ 4.0 in order to call some complex API functions through VS.NET 2003. But, VS.NET 2003 is generating an error at below;
An unhandled exception of type 'System.MissingMethodException' occurred in tester.exe
It is an WCE MFC AppWizard (dll) project. I cannot call even simple function. Sample code at below;
EXTERN_C
__declspec(dllexport)
int Tester(int a, int b)
{
return(a+b);
}
VS.NET code is a "Smart Device Application";
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Declare Function Tester Lib "wtest.dll" (ByVal a As Integer, ByVal b As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim c As Integer
c = tester(1, 1)
End Sub
End Class
I can see the "Tester" function at dumpbin output. Also, I declared "Tester" in .def file at below;
; wtest.def : Declares the module parameters for the DLL.
LIBRARY "WTEST"
;DESCRIPTION 'WTEST Windows CE Dynamic Link Library'
EXPORTS
Tester
; Explicit exports can go here
What do you suggest about this problem?
Regards,
Orkun GEDiK
SAP R/3 Software & System Support Specialist
ASTRON
|
|
|
|
|
I was reading through an article by Jan
Visual C and C++ (General) Technical Articles
C++: Under the Hood
Jan Gray
March 1994
struct P {
int p1;
void pf(); // new
virtual void pvf(); // new
};
struct Q : P {
int q1;
void pf(); // overrides P::pf
void qf(); // new
void pvf(); // overrides P::pvf
virtual void qvf(); // new
};
Most C++ implementations will share or reuse an inherited base’s vfptr. Here Q did not receive an additional vfptr to address a table for its new virtual function qvf(). Instead, a qvf entry is appended to the end of P’s vftable layout. In this way, single inheritance remains inexpensive. Once an instance has a vfptr it doesn’t need another one. New derived classes can introduce yet more virtual functions, and their vftable entries are simply appended to the end of their one per-class vftable.
Does that mean Q will use P's vftable? If both P and Q share the same vftable?
I could not get exactly if some one can help me understand that properly?
|
|
|
|
|
I have a wrapper function generated by the ClassWizard from a type library which goes like this.
<br />
VARIANT ClassA::GetSession(const VARIANT& varItem)<br />
{<br />
VARIANT result;<br />
static BYTE parms[] = VTS_VARIANT;<br />
InvokeHelper(0x7dd, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,<br />
&varItem);<br />
return result;<br />
}<br />
I result is an object of ClassB. How do I convert the VARIANT to an object of ClassB and call it's methods ?
|
|
|
|
|
Hi,
I'm trying to use the IShellFolder::GetDisplayNameOf method to get the filename in a drag drop application. But the function behaviour is dependent on the display settings of folders. When i choose to hide file extensions for known filetypes it creates problems and returns only the filename(no extension) and if i choose to display extensions for all files i get the filename with extension.
Can someone please tell me how to get rid of this behaviour i.e. get the filename with extension no matter what the folder displayt settings are.
Thanks in advance,
DS
|
|
|
|
|
Digvijay Singh Chauhan wrote:
I'm trying to use the IShellFolder::GetDisplayNameOf method to get the filename in a drag drop application. But the function behaviour is dependent on the display settings of folders. When i choose to hide file extensions for known filetypes it creates problems and returns only the filename(no extension) and if i choose to display extensions for all files i get the filename with extension.
I would think this to be intended behavior as that is what "display name" implies. If the shell has been configured to hide the file extension, shouldn't the interface respect the setting?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|