|
When ReadProcessMemory() returns FALSE, what does GetLastError() return?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I solved the problem. The cause was, that (for what reason soever) the last 8 bytes of the heap block were locked for reading. If I exclude those bits, the function works as expected.
Thanks for your post, though.
Tobias
|
|
|
|
|
Hello,
(I thought I should post this in the Visual Studio IDE forum but it says not to post any programming questions there)
I am trying to move from VS 6 to VS 7 (aka .NET, aka 2003). The class wizard seems to be gone and instead replaced by options to add methods/variables/properties etc. How does one remove/delete methods/variables/properties without manually editing the code now that the wizard is gone.
Secondly and more importantly, in VS 6 you could create a new project and select from the wizard the project's type to be MFC ActiveX Control. The wizard then allowed you to set the number of ActiveX controls the project should have. The problem with this was that once you set the number of controls, you could not later add more controls to that project (or is there?). The only way to do this as far as I know is to RESTART a new MFC ActiveX control project setting the control number higher and importing all the previous files again.
In Visual Studio .NET when I create a new project of type MFC ActiveX Control, I no longer have the option to enter the number of controls the project should contain. As a result that project can only have one control. This raises the questions on whether this means there is now a method to add more controls to the project at a later stage instead of specifying such a number from the very begining and being stuck with it. Is this the case? How can I set the number of controls an ActiveX Control project has in Visual Studio .NET?
Where have all the wizards gone?
Thanks,
Aristotel
|
|
|
|
|
greekgoddj wrote:
The class wizard seems to be gone and instead replaced by options to add methods/variables/properties etc. How does one remove/delete methods/variables/properties without manually editing the code now that the wizard is gone.
The Class Wizard is gone. You can add new member methods/variables/properties by using the menu, but you must delete them manually. There's no auto-deleting option built-in. The new way to override virtual methods (such as adding Win32 message handlers) is to click on a class name in Class View, then use the Properties box on the right. I think this was a good introduction, because the code Class Wizard used to generate looked ugly as hell. You can further enhance your productivity by installing a third-party tool such as Visual Assist.
greekgoddj wrote:
-- Is this the case? How can I set the number of controls an ActiveX Control project has in Visual Studio .NET?
Your approach is wrong. To create a multi-control ActiveX component, create an ATL Project (wizard) first. Call it 'My Controls', for example. Then go to Class View, choose 'Add Class' and select 'ATL Control' as type. This adds a new ATL ActiveX control into the project. Another method is to create an MFC ActiveX Control, then add ATL support and add ATL Controls like above.
The MFC Class Library has been merged with ATL, creating the ATL/MFC Library which currently exists in VS 2003. This is visible through the documentation, and the introduction of classes like CStringT. It is _strongly_ encouraged to use pure ATL in creating ActiveX Controls. That is what ATL was built for: ActiveX Template Library.
greekgoddj wrote:
Where have all the wizards gone?
You know how wizards are: short-tempered and quick to anger. It seems they've decided to take a leave. Microsoft became with a whole new approach to the wizard theme, replacing them with scripted dialogs that only generate pure code and cease to exist after they've been ran. This removes things like Class Wizard database files (which were always corrupt) and the ugly-looking defines and insertion point markings with triple-backslashes. I think it was a good thing. The code's clear, good-looking and easy to follow. It does introduce some more manual work, but using the mouse and Delete, I think it's pretty easy to remove unneeded variables/methods.
Then about the versioning. Visual Studio version 6 was version 6. Version 7 is .Net 2002 and 7.1 is .Net 2003. Version 8 will be 2005, when it's released.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Thanks!
I have gone ahead and started moving my MFC based ActiveX Control projects to ATL ActiveX projects with ATL controls supporting MFC.
So far so good, however i do have the following problem with using ATL.
In the MFC only version I was calling
[code]
Invalidate()
[/code]
everytime there were changes made to values that required for the display to be redrawn. Calling the same function in the ATL version of the ActiveX Control, gives me an assertion message.
The part of the code the causes this message is
[code]
BOOL Invalidate(BOOL bErase = TRUE) throw()
{
ATLASSERT(::IsWindow(m_hWnd));
return ::InvalidateRect(m_hWnd, NULL, bErase);
}
[/code]
I have not worked with ATL before. Has anybody come accross this before, and how does one tell the ActiveX control that it needs to update the display/graphics?
Thanks in advance!
Aristotel
|
|
|
|
|
Great,
afte loosing 2 hours or so on this matter, AFTER posting this thread, I found the answer. Well for those who need it in the future the answer is:
[code]
FireViewChange()
[/code]
Ciao
|
|
|
|
|
If it causes an assertion, the reason is clear. Apparently you're calling Invalidate for the CWindow-class. If this class's m_hWnd member is not a valid window, it will cause an assertion.
The most common reason for this is that your CWindow class is not properly constructed, initialized and created. Perhaps you're calling Invalidate too early ? To avoid this, add a conditional sentence in front of your Invalidate call that will check if the window in question is valid. This way, Invalidate will only be called on valid windows and the assertion will never fire.
Otherwise, ATL has nothing in special compared to MFC or Win32. The CWindow::Invalidate will call InvalidateRect Win32 function to do it's task.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
i have a program that it read dxf. but my program only read simle's dxf.
hope have i that friend help to you . my program project is send to your friend.please your email to me
yangxjn@hotmail.com
yangxjn@163.com
MSN:yangxjn@hotmail.com
|
|
|
|
|
What exactly are you asking (or telling us) here?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I am currently trying to communicate via the COM port with a device of mine. For now, the device just echoes immediatly the character it receives.
PC Platform: WinXP Pro, MS VStudio 6.0, VC++
I read some articles from the site (really helpful, like to thank konchat, Ashish Dar - good articles for head start in Win API serial port programming) and tried to send some chars through the serial port and subsequently reading the char return by the device. (note: already tried the device with hyperterminal and it echoes well, no hang-ups or smth).
I used 8n1, non-overlapped mode for the serial port.
at first it seemed the program works, when trying to send (e.g. characters 65 to 90 ASCII) by the 24 char (Y) the program doesn't receive characters any more (they still get to the device as it shows me which chars arrived by flashing LED-s connected to a register).
Even stranger, if a run the program.. stop it, say it.. after the 10 sent character and run it again, exactly at the 14 char it will stop receiving data. (10+14= ??!!! exactly, 24).
Is there something i am doing wrong?. Here the code that does the sending:
<br />
<br />
DCB dcb = {0};<br />
dcb.DCBlength = sizeof(DCB);<br />
DWORD dwBaudRate=9600;<br />
BYTE byStopBits=1,<br />
byByteSize=8, <br />
byParity=NOPARITY;<br />
COMMTIMEOUTS cto;<br />
const HANDLE hPort = CreateFile( portname,<br />
GENERIC_READ | GENERIC_WRITE, <br />
0, <br />
0, <br />
OPEN_EXISTING, <br />
0,
0);<br />
<br />
if (hPort == INVALID_HANDLE_VALUE)<br />
AfxMessageBox("Could not open "+portname+" port.");<br />
else<br />
{<br />
cto.ReadIntervalTimeout = 1000;<br />
cto.ReadTotalTimeoutConstant = 1000;<br />
cto.ReadTotalTimeoutMultiplier = 1000;<br />
cto.WriteTotalTimeoutConstant = 1000;<br />
cto.WriteTotalTimeoutMultiplier = 1000;<br />
SetCommTimeouts(hPort, &cto);<br />
int index=1;<br />
for (int k=0; k < 10; k++)<br />
for (int i=65; i< 91; i++)<br />
{<br />
char outb[1],inb[1];<br />
DWORD sent,read;<br />
outb[0]=(i);<br />
if (WriteFile(hPort,outb,1,&sent,NULL)==0)<br />
{<br />
AfxMessageBox("Error Writing to "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << index << ": sent=" << char(outb[0]) << " ";<br />
index++;<br />
inb[0]=0;<br />
if (ReadFile(hPort, inb, 1, &read, NULL)==0)<br />
{<br />
AfxMessageBox("Error reading from "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "rcvd=" << char(inb[0]);<br />
if (outb[0]==inb[0]) <br />
std::cout << " ... OK";<br />
else<br />
std::cout << " ... NOK";<br />
std::cout << std::endl << std::endl;<br />
PurgeComm(hPort, PURGE_TXABORT | PURGE_RXABORT | <br />
PURGE_TXCLEAR | PURGE_RXCLEAR);<br />
}
<br />
}
if(CloseHandle(hPort) == 0)<br />
{<br />
AfxMessageBox("Error closing "+portname+" port.");<br />
nRetCode=1;<br />
}<br />
std::cout << "Port " << portname << " closed." << std::endl << std::endl;<br />
Any ideas, anyone?
Looking forward to your replies.
Found the bug. If anyone steps across this one in future: when using Win API for Serial Port access, always set the DCB Structure or else the code will work only partially (only God and Bill Gates know why but... who am I to judge :P ). I used a system call "system('mode COM1..... ');" to set the com parameters and the API doesn't seem to cope very well with that.
Anyways... Happy coding
Nik0n
|
|
|
|
|
|
Hi, Thx for the reply.
No handshake for now: no hardware rts/cts nor software xon/xoff. just wanna see it run for a
while, no packet dropping, no hang-ups.
It's just a preliminary test before writing the software for the device.
Nik0n
|
|
|
|
|
Thanks in advance.
I want to display a transparent label on a dialog; where as a bitmap is set as the dialogs background.
The problem is that if the text in label is not changing its fine, but if the numbers in label are changed they overwrite the previous one creating black squares at each charchter position.
Here is how i set the image as back ground of dialog;
void MyDlg::OnPaint()
{
CPaintDC dc( this ); // Device context for painting
CBitmap bmp, *poldbmp;
CDC memdc;
bmp.LoadBitmap( IDB_BITMAP13 );
memdc.CreateCompatibleDC( &dc );
poldbmp = memdc.SelectObject( &bmp );
dc.BitBlt( 0, 31, 1009, 521, &memdc, 0, 0, SRCCOPY );
memdc.SelectObject( poldbmp );
// Do not call CDialog::OnPaint() for painting messages
}
The problem remains same if OnEraseBkgnd function is used for background image;
And here is how I display a Transparent Label:
HBRUSH CDBDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID() == IDC_L1) // IDC_L1 is label ID
{
pDC->SetBkMode(TRANSPARENT);
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hbr;
}
static labels are absolutely fine but the changing ones mess up.
|
|
|
|
|
Let say I want to develop a system that can keep all the student information. So if I click at 1 of their name, this system will display their profile information (include photo). The problem now is I don't know how to upload their photo into this system. Can anybody help me pls..
|
|
|
|
|
If the Web Service support XML language and can be reached with SOAP or HTTP protocols, then MSDN has all the information you could ever need[^].
If it's not a XML Web Service, then you must find out what protocol it uses and what queries it replies to. Then build a manual Internet-connection object, initialize and connect it to the web service, create query strings manually, and post them through the object to the service. Then read the results and interpret them according to the documentation of the Web Service.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
I am working on the reporting part of a big project. The problem is that the users of the product can have either version 8.5 or 10.0 of crystal reports. The task is to identify the version of the crystal report they have on the system and then create the relative activeX control either 8.5 or 10.0 from the code using its dlls to display the reports.
I know that I can extract the version and the path of the dlls from the registry of the system. The actual problem arises when i need to use that dll to create the control dynamicallyfrom the code at runtime and use it to display the reports.
Hope some one could help me out.
Thanx in advance.
..RR..
|
|
|
|
|
hi rahim,
suppose if the two version dll's are named as crystal32_8.dll and crystal32_10.dll. then u register the both the dll's in the registry, then instantiate both the dll's classes. Then in the reporting function try to read the version of the report file and based on the version call the appropriate object.
{
// in the main class
CCrystal_8 m_cry8 ; // object used to get the services of crystal32_8.dll
CCrystal_10 m_cry10 ; // object used to get the services of crystal32_10.dll
}
{
//in the area of reporting the file
int ver ;
1. get the version info of the report file and store it in the ver
2. if(ver == 8)
//use the object m_cry8 to show that file
else
//use the object m_cry10 to show that file
}
naren
|
|
|
|
|
I have the code as
DEVMODE devmode;
devmode.dmFields = DM_ORIENTATION;
devmode.dmOrientation = DMORIENT_LANDSCAPE;
devmode.dmSize = sizeof(DEVMODE);
CPrintDialog g_dlgPrt(FALSE);
g_dlgprt.DoModal();
Before showing the print dialog box , i want to set the radio button to landscape in the dialog box.
I tried the following code,
HGLOBAL hgdvmode = GlobalHandle((LPCVOID)&devmode);
g_dlgprt.m_pd.hdevmode = hgdvmode;
But this not working .
can you help in this regard.
|
|
|
|
|
See the MSDN example Q193103.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you.
I too got the solution..
LPDEVMODE pDMX = NULL;
CPrintDialog prtdlg(FALSE);
pDMX = (LPDEVMODE)GlobalAlloc(GPTR, sizeof(DEVMODE));
if (!pDMX) {
MessageBox("Out of Memory");
return FALSE;
}
// Initialize the DEVMODE structure.
pDMX->dmSize = sizeof(DEVMODE);
pDMX->dmFields = DM_ORIENTATION;
pDMX->dmOrientation = DMORIENT_LANDSCAPE;
prtdlg.m_pd.hDevMode = pDMX;
|
|
|
|
|
Hi. I have an ActiceX that I’d like to communicate with a web service. I assume it is possible to do it but I don’t know where to start.
I know how to create a web service (using C#) but it’s the call from the “old” ActiveX that’s not clear to me.
_____________________________
...and justice for all
APe
|
|
|
|
|
I assume you're using C++ here. MSDN has instructions for you right here[^]. The consuming of Web Services in C++ is very similar to C#, with the exception that C++ requires wrapper class generation (which is done automatically for you). I hear Visual Studio 2005 is different in this aspect, as the C++/CLI is introduced. Consuming Web Services in this environment is pretty much the same for C# and C++.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Ok, the tutorial on MSDN starts with:
On the Project menu, click Add Web Reference to display the ...
I'm using Visual Studio 6.0...
_____________________________
...and justice for all
APe
|
|
|
|
|
Ahh, so you're using VS 6.0.
Unfortunately this version of Visual Studio does not have a direct Web Services support, like it doesn't have C# support at all. You need to do everything manually in this version. Manual labor is highly difficult and most prone to errors. In order to efficiently use Web Services, I recommend you to move into Visual Studio 2003 .Net version.
If you must use VS 6, then start by learning SOAP, as it's the "language" of Web Services. Then create an Internet-connection, open a HTTP connection to the Web Service, generate a string that can be interpreted as a SOAP request with the proper parameters, post a HTTP Post command into the service and fetch results with HTTP Get. I'm sorry I can't give any more detailed instructions or specific help, because I've never done this manually. The auto-generated wrapper classes (Add Web Reference) have saved me the task.
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Hi
I have a CString type variable that Content is Numberic
how can get this CString as a Integer?
|
|
|
|
|