exactly same code, warning C4311: 'type cast' in a MFC dialog, no warning in console application i have a window console application used to generate signal ouput from a board. When i try to write this into a MFC dialog, using the same code(i mean a specific part), a warning occurs.
The signal generator board comes with its own .h file and library that includes driver functions.
in one .h file, following types are defined:
# define int16 short int # define int32 long int # define ptr8 char*
in the library, following driver function prototype is defined;
HEAD SpcSetParam (int16 nNr, int32 lReg, int32 lValue);
in my header file; i declared 2 char pointers:
ptr8 pbyData[2];
in my cpp, i allocated 2 char array;
for (i=0; i<2; i++) pbyData = (ptr8) GlobalAlloc (GMEM_FIXED,1024);
then i write data to the array,and need to pass the address of this two array to the driver function.
Using the function provided:
for (i=0; i<2; i++){ nErr = SpcSetParam (hDrv, SPC_FIFO_BUFADR0+i, (int32) pbyData ); <---------warning occurs here
ignore the nErr and hDrv, SPC_FIFO_BUFADR0+i is the value for specific register, and (int32) pbyData i think is the address of the the array
the code works fine in console application, no warnings, however, using the same code in a MFC dialog, following error generated:
warning C4311: 'type cast' : pointer truncation from 'char *' to 'long'
could anybody tell me whats going on and how to fix it Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Problem with MSVC 2005 Express Edition runtime on Windows 2003 I install VC on Windows 2003 sever and build my program using command line, not IDE. Then I try to run programm on this server and Windows throw error 6034. Before runing I copy Microsoft.VC80.DebugCRT to the folder with my programm. I can't call GetLastError because for this I need recompile runtime. Can I disable manifest checking at all Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Passing file handle across processes In Addition to Einar's comment,
Handle's are local to the process and those are storing inside the handle table of the process. If you want to transfer an open handle to another process, you must use the DuplicateHandle API. You've got to use DuplicateHandle to insert an entry into the target process's handle table. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Creating Account on windows Mail
Hi,
What is the way to create the windows mail account using pop3 and smtp server name.
I knew that I think IImnAccountManager could do this,but this interface has been
deprecated now for vista and also login of creating account been changed in vista.
Vista is creating one .oeaccount file for each account into
"%UserProfile%\Local Settings\Application Data\Microsoft\Windows Mail". folder.
but here I am facing issue of setting binary password and setting as a default account.
Please help me if anybody knows anything about this,that would be great for me to know something more about windows mail.
Thanks,
Prakash. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Bizarre bug using std::ofstream and TRACEFILE einaros wrote:
To avoid the problem, remove the preprocessor definition from your source file, and place it in the project settings instead. Well first I must say that I am embarrassed. That is so obvious I should have spotted it. Another possibility is to put "#define TRACEFILE" in TestLogger.cpp. Regardless, the cause is obvious now, I understrand the problem and solutions and I now agree that it is not a bug. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
How to convert Byte/Int data to Hex Have a look at http://einaros.blogspot.com/2006/11/put-hex-on-that-dump.html . While I don't think that's quite right for you, you may pick up on what you need to do to display hex encoded data. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Temporary ostringstream buffer overflow Hi
When using a temporary ostringstream, VC++ 8 SP1 seems to have a buffer overrun. The below code works before in older VC++.
#include <iostream>
using namespace std ;
#include <sstream>
int main ()
{
cout << static_cast < std :: ostringstream &>( std :: ostringstream () << "" << "TEST" ). str (). c_str ();
return 0;
}
The console output is
0041774BTESTPress any key to continue . . .
It should be just
TESTPress any key to continue . . . Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Compiler Bug (KB140670) resurrection in VC 2005 ? I have discovered that simple code :
int a=0;
typeid(a).name();
Lead to memory leak report in MFC application.
The crtdbg in VS2005 reports memory leak after using simple RTTI
For example Create Single Dialog MFC Application and write that code inside BtnOkClick() handler
and you'll see leak report.
This is old bug which was fixed in VC++ 2003
http://support.microsoft.com/kb/140670 Tag: Visual C++ General Graphics - a hidden buffer Visual C++
New to Visual C++ Hello,
I am trying to tie a CLOSE button to a form..
Any idea about the code needed to do that
Appreciate it..
Diver Tag: Visual C++ General Graphics - a hidden buffer Visual C++
filling and writing multidimensional vectors Mike Danes wrote: I was wondering how much time I have left to live until someone kills me for that comment
Not much, it seems. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
convert VS6 -> VS 2005 and ON_EVENT_ doesn't work I've just converted a VS 6 project to VS 2005. I converted by opening the VS 6 project in VS 2005 and accepting the conversion option. Two errors occur (1) during a build I get a 'hcw' file not found, and during execution my ON_EVENT_s aren't honored. Help says that 'hcw' is a tool. I suppose I'd like to remove it but I don't know how. Redoing the ON_EVENT_s would be a real chore, is there anything I can do to recover the old events after conversion - they are all still in the Dialog subclass header and in the BEGIN_MESSAGE_MAP section of the .cpp file. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
My Program Takes a lot of Memory Hello, In The program I have 120 Pic , 2 MB in size, I've made a managed resource file(.resx) and add pics in that (as embedded resources) when i want use them, I define a IdictionaryEnumerator in order to enumerate pics. when I use GetEnumerator() method it add 30 MB to my Memory used by the program. Please tell whats It's resoan and what should i do to get rid of such a problem And is there another way taking less memory to enumerate resources Thank You. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Replacing dbghelp.dll with the newest version in VS 2003? Hi, would it be a good idea to replace dgbhelp.dll with the newest version from debugging tools Replacing the old header and
compiling & distributing with the new dll I currently use VS 2003 and program generates minidumps when it crashes. Best wishes, Andy Tag: Visual C++ General Graphics - a hidden buffer Visual C++
command line options for stripped pdb Hi All, I like to have my project generate stripped pdb file in command line option. I tried with the following options in my command line: msdev myproject.dsw /MAKE /LINK /PDBSTRIPPED:Test.pdb there was no error once I run the command, but it didn't generate stripped pdb file named "test.pdb" in the folder. I also tried the other way as: Link /PDBSTRIPPED:Test.pdb but it didn't work either. Anyone has any suggestion Thanks, vcfan Tag: Visual C++ General Graphics - a hidden buffer Visual C++
passing control handle to unmanaged directx dlls to paint - result is flickering! Hi, I have a third party unmanaged DLLs which requries a window handle to do some painting on. My attempts have been to pass the control::handle property to this DLLs. The DLLs declaration expects a void* hWnd. Below is the declaration.
CyResult CyDisplayEx:: Open
(
void *
aWindow ,
unsigned short
aColumns = 1 ,
unsigned short
aRows = 1 ,
bool
aFullScreen = false
)
[virtual] What I did was is follows. Panel* test = new Panel(); System:: Intptr handle = test->Handle; void __pin* hwnd = (void*)handle; CyDisplayEx:: Open(hwnd, 1,1, false); The result & problem The unmanaged DLL starts painting in the window area. It continues to update with significant flickering. At this point, I have not managed any of the paint event to that window. Additional information about the 3rd party DLL. I know that the DLL uses directdraw to paint in the window. It also has the following notes:
Note:
On Windows, the aWindow parameter must be a valid HWND (WIN32 SDK). It is important that the user¡¯s window handling call the following functions on specific Windows events:
WM_MOVE ==> OnMove( unsigned int aPosX, unsigned int aPosY ) ;
WM_SIZE ==> OnSize( unsigned int aSizeX, unsigned int aSizeY ) ;
WM_PAINT ==> OnPaint() ; I have been strugling with this for almost a week If anyone has any insight, PLEASE don't hesitate to help. Thanks! Tag: Visual C++ General Graphics - a hidden buffer Visual C++
CryptUI.dll I recently created an application that is using a function in CryptUI.dll. I developed this application on a Vista machine, and then tested it on an XP machine. Everything works great.
However, I moved the program to a Windows 2003 system and the program fails. I get an error message that says Windows can't find the entry point for my function (CryptUIDlgSelectCertificateFromStore) in CryptUI.dll. I tried copying the dll over from my XP machine to my Windows 2003 machine, but that didn't work either. Does anyone have any ideas how I can solve this problem
Thanks in advance. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
a problem ablut the reference in<think in c++>2th Page 453
the author said :Once a reference is initialized to an object ,it cannot be changed to refer to another object " but form the code I can see the reference is changed to refer to another
is the auther wrong ¡¡PS¡¡I am using dev C++
#include<iostream> using namespace std;
int main(int argc,char* argv[]){ int i,k=3; int &x=i; i=1; cout<<x<<endl; i=0; cout<<x; x=k; cout<<x; system("pause"); } Tag: Visual C++ General Graphics - a hidden buffer Visual C++
"Unresolved external symbol" after upgrading to VS05 Hi All, I have a project that build and worked fine all the way through Visual Studio 2003. After upgrading to VS2005 and rebuilding the two dependent libraries I am receiving a linker error on the parent DLL stating: Error 1 error LNK2001: unresolved external symbol _hInstDLL stdafx.obj Error 2 error LNK2001: unresolved external symbol _hInstGenDLL stdafx.obj There is a common header included in one of the libraries and the parent DLL. All files are C++. I can't get rid of the "extern "C"" section because of legacy stuff elsewhere. That header file contains amongst others the following code:
#ifdef
__cplusplus
extern "C" {
#endif extern HINSTANCE
hInstDLL;
extern HINSTANCE
hInstGenDLL;
One of the source files in the library contains the following code fragment:
extern "C"
{
HINSTANCE hInstDLL1Way; HINSTANCE hInstGenDLL;
}
As you can see ( and not for the lack of a blinking cursor in this window on my FireFox browser ), I am defining the two variables. The library builds cleaning with no errors or warnings. The main DLL builds cleanly to, but now throws a the two linker errors, which is really one linker error. The old version of VS (2003) correctly located the two symbols in the library. What do I need to do now Thanks in advance, Marci Weinberger Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Semaphores Hi,
I'm learning about semaphore, and I'm trying to write a simple program using it.
The program:
each time a semaphore reaches 4 (in his counter), it will zero it self and start again.
Can any one show how to do that
MyProgram:
HANDLE X;
void main()
{
X = CreateSemaphore(NULL, 0, 4L, NULL);
CreateThread( NULL, 0, X_func , Data, 0, NULL);
CloseHandle(X);
}
DWORD WINAPI X_func(LPVOID data)
{
MyData* Data = ((MyData*)data);
while ( true )
{
WaitForSingleObject(X , INFINITE);
ReleaseSemaphore(HydrogenReady, 1, NULL )
}
} Tag: Visual C++ General Graphics - a hidden buffer Visual C++
VS .Net 2005, how to disable intellisense... There is a undocumented way to disable C++ Intellisense: Rename or delete the following file: <VS root path>\VC\vcpackages\feacp.dll Tag: Visual C++ General Graphics - a hidden buffer Visual C++
LNK2019: unresolved external symbol error when i compile my win32 app wheni try to compile my app i get this error: MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup Debug\Employee.exe : fatal error LNK1120: 1 unresolved externals please tell me how to fix it Tag: Visual C++ General Graphics - a hidden buffer Visual C++
How to write include statement compatible to both unix and windows Hi ,
Iam integrating a piece of functionality which was developed in unix environment. while developing with MFC framework i have some problem with the include statements.
include statement originally : #include"headers/header.h"
include statement in vc++ : #include"headers\header.h"
or #include"headers//header.h"
to change manually these statements ...... :-(
is there any way to make it work without changing
please let me know.
Thanks,
Srikanth. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
VS .Net 2005, how to disable intellisense... There is a undocumented way to disable C++ Intellisense: Rename or delete the following file: <VS root path>\VC\vcpackages\feacp.dll Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Not able to dump a multibyte character Unicode(utf8) encoded data to a file Dear all,
I am writing a network project that must support multiple human languages like Chines, Arabic, Thai ...etc. using a native win32 C++ with Microsoft Visual C++ 2005 express edition on windows xp pro.
Precisely, I have to dump log data to a log file, these data could be written with different human languages as I mentioned above. When I gave a try to implement an output streaming to a file, I failed in dumping other than English language data. And the target file will show only question marks " '
However, the code that I wrote is show below: Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Creating CoClass in ATL using VS 2005 Hi All,
I recently started working in VS2005 environment, and having a background of VC6.0. I just created a smple ATL application under 2005, and just wondering if any option is available in the IDE for creating a coclass of the ATL component, as we does in VC6.0 IDE by using Insert->New ATL Object Please help me on the same. Thanks in advance.
Regards,
Abhinav Tag: Visual C++ General Graphics - a hidden buffer Visual C++
LNK4099 problem. Hi,
I am using a 3rd party SDK to build one sample DLL application. I am using their static lib to link with my project.
During linking, I am getting the following warning message:
gdal.lib(cplgetsymbol.obj) : warning LNK4099: PDB 'vc80.pdb' was not found with '..\dev\dw32\gdal.lib' or at '..\dev\dw32\vc80.pdb'; linking object as if no debug info
There are lots of such warnings. I am using VS2005 to build my application.
In code generation I am using Multi Threaded Debug DLL (/MDd).
Can you tell me the way to remove LNK 4099 warnings and what is the cause for this
Regards
Sunil Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Always Recompile unnecessary files (not modified files) [SOLVED] Hi, I'm having trouble with Visual Studio .NET 2003. I was developing an application for one year ago and when I clicked to build solution, it compiles only the files that where modified. Since one month ago I have reinstalled Windows and Visual Studio and when I try to build the project, it always compile all the files in the project. I don't understand what's happening because I didn't changed any option. Thanks, -------------------SOLUTION------------------- Hi, finally I have found the problem. I have a "definitions.h" file that contains some definitions. One of this was the PI number. Now I have deleted this definition and I use the M_PI constant from "math.h". I don't understand why but now the project only builds if I make any change and only compile these files. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
why the fread function is crash? I have use one Dll that maked by another.this DLL is compiled with /MT.in this DLL ,he receiver one FILE pointer from my own program,then call the function fread to read data fron file .
my program is compiled with /MT also, I send the stdin to the DLL.but when the function fread is running ,it is crash.
I check my code and the dll code ,all have not error .
so I do not get the reason of error. Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Open a form / ->ShowDialog problems. Hi. I am trying to learn C++/CLR but it seems very tricky compared to things I have done in the past. I wish to open a second form when I click a button, it should be simple but just refuses to work. From the MSDN:
Code Snippet
void ShowMyDialogBox() { Form2^ testDialog = gcnew Form2; // Show testDialog as a modal dialog and determine if DialogResult = OK. if ( testDialog->ShowDialog( this ) == ::DialogResult::OK ) { // etc etc etc. However, I have added a second form (Project->Add New Item->Windows Form) Form2. When I get to testDialog->ShowDialog(this) it says "Expression to the left of . or -> has a type which could not be resolved". I have done lots of fiddling but cant work out what I am doing wrong. When I type it all in anyway I get the following compile errors; Error 1 error C2065: 'Form2' : undeclared identifier 86 Error 2 error C2065: 'test' : undeclared identifier 86 Error 3 error C2061: syntax error : identifier 'Form2' 86 Error 4 error C2227: left of '->ShowDialog' must point to class/struct/union/generic type 87 Any ideas I had it working in seconds using C# and obviously a minor alteration of code. Another thing I noticed was that C# IDE has a much better autocomplete feature than the C++ IDE, is this just a problem with me, or is it meant to be like it Thank you for your time! Tag: Visual C++ General Graphics - a hidden buffer Visual C++
Problem while trying to implement an interface exposed by a type library in VC++ Hello, I have an MFC application that has been built using VC++ 6.0. It is a 'full server' executable. I import a COM dll into my VC++ project by using the following: # import <COM_DLL> no_namespace no_implementation raw_interfaces_only named_guids This creates the type library for the dll (with the name COM_DLL.tlh). The COM_DLL that I am importing has an interface. This (dual) interface is being exposed as a "struct __declspec " in the .tlh file. I want to implement this interface, as this is essentially for a callback. I am new to the world of VC++ and don't know how to proceed ahead :( Searching over MSDN did not help much either - perhaps I am not searching for the right thing. I would highly appreciate if someone could give me some pointers on how to proceed ahead with implementing the interface. Thanks, Ankit Tag: Visual C++ General Graphics - a hidden buffer Visual C++
bucz
I want to draw some plot. I want to draw some objects, like grid, once and then only paste them on puropse into the target graphics context in OnPaint().
How to make a kind of "buffer" for this image of the grid