error LNK2022: metadata operation failed - using Templates?
I've seen several previous posts related to LNK2022 errors using
templates, but I have not seen a resolution (one other person said the
error goes away if he does not make his class a template, but that's
not a preferred solution for me, as it wasn't for him) .
I have a template LinkedList class that I can use successfully within
the .Net form.h file, but if I try to access it from within another
class (only in that class, no longer in the form) it compiles fine but
then I get two link errors:
City.obj : error LNK2022: metadata operation failed (80131187) :
Inconsistent method declarations in duplicated types (types: node;
methods: .ctor): (0x06000003).
City.obj : error LNK2022: metadata operation failed (801311D6) :
Differing number of methods in duplicated types (node): (0x02000004).
I've commented out most of the lines of code so I know that this error
occurs when I include a method call from with the City object to the
linked list method insertAtHead.
The linkedlist class (reduced for this example) is:
#pragma once
template <typename Item>
ref class LinkedList
{
private:
ref class node
{
public:
node() { data = Item(); link=nullptr; }
node(const Item% init_data, node ^init_link)
{ data = init_data; link = init_link; }
Item data;
node ^link;
};
public:
typedef node ^NodePtr;
LinkedList(void);
void insertAtHead(const value_type% entry);
private:
NodePtr head;
};
and in the cpp file:
template <typename Item>
LinkedList<Item>::LinkedList(void)
{
head = nullptr;
}
template <typename Item>
void LinkedList<Item>::insertAtHead(const Item% entry)
{
head = gcnew node(entry, head);
}
In the City class, I have:
#pragma once
#include "LinkedList.cpp"
ref class City {
public:
City(System::String^ cityName);
void addDest(City^ dest);
private:
System::String^ name;
LinkedList<City^> destList;
};
and in the City.cpp file:
void City::addDest(City^ dest) {
destList.insertAtHead(dest);
}
If I comment out destList.insertAtHead(dest); I no longer get the
linker errors.
As stated above, the LinkedList files (unmodified) work if I put the
declaration of the linked list and calls to insertAtHead in my Form1.h
file. Why should it make a difference if they are in my City class
instead?
Any suggestions would be greatly appreciated!
cyndi Tag: red exclamation mark icon Tag: 266678
dllregisterserver not registering com classes
I have a COM DLL (created with the ATL COM wizard). It comes with the
function:
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// registers object, typelib and all interfaces in typelib
HRESULT hr = _AtlModule.DllRegisterServer();
return hr;
}
This function does get called when the object is registered, but none
of the interfaces I have defined get registered.
Do I need to put code in to manually register my objects? What does
that function register, then?
Thanks,
-PaulH Tag: red exclamation mark icon Tag: 266671
Making Type Library for normal Windows DLL (not a COM server)
I read this artical and tried to create tlb for my C++ class.
import "oaidl.idl";
import "ocidl.idl";
[
uuid(634FE8B5-C847-4b25-B135-B39312741EDE)
]
library Vdll_1Lib
{
importlib("stdole2.tlb");
[
dllname("Vdll_1.dll")
]
module Vdll_1Mod
{
//[entry(1)] void Calculate_1(void);
[
entry("Calculate_1")
]
void Calculate_1 (void);
}
};
----------
LIBRARY "Vdll_1.dll"
EXPORTS
Calculate_1
------
#import "C:\Test\Vdll_1\Debug\Vdll_1.tlb"
I am getting linking problems .
ClientClass.obj : error LNK2019: unresolved external symbol "void
__stdcall Vdll_1Lib::Calculate_1(void)" (?Calculate_1@Vdll_1Lib@@YGXXZ)
referenced in function "public: virtual long __stdcall
CClientClass::Add(wchar_t *)" (?Add@CClientClass@@UAGJPA_W@Z)
Debug\ClientVdll.dll : fatal error LNK1120: 1 unresolved externals.
Any suggestions for this issue?
thanks
abhi Tag: red exclamation mark icon Tag: 266662
VC++ vs. FoxPro
I've generated a DLL with Visual FoxPro 9.0 and, on the other side, I've go a
VC++ project wich uses DLL methods. I Copy the TLB file into VC++ project
folder and the I rebuild EXE.
If I create the DLL in VFP 6.0 it works ok, but if I do in VFP 9.0, when I
build EXE, it says 'Function does not take <n> parameters'.
I call DLL functions in this way:
vResult = Iobj->mymethod(vparam, vparam, ...); Tag: red exclamation mark icon Tag: 266659
Urge for help in a game programming
Four Win
Description
To program the play named "four win", the background board should
consist of a lattice with 7 columns, into which in each case 6 stones
fit. The playing field stands perpendicularly, so that a stone falls
always widen-possible downward.
The rules are :
1=2E The goal of the Game is to place four stones in a row or column wise
or diagonally as a first player.
2=2E Each player receives 21 stones of his colour (pink/green).
3=2E The green player begins.
4=2E The player lets a stone fall alternating into a row.
5=2E If no more places are in a row, then this may not be selected.
6=2E Winner will be the player, who can accommodate first four stones in
a continuous manner (horizontally, vertically, diagonally).
7=2E If the backboard is full and there is no certain winner, then the
play ends undecided.
For a better understanding go to:
http://www.kielack.de/games/fourwins.htm
The program is to cover the following capability characteristics:
=B7 Play between two human players.
=B7 Play between a human and a computer player.
=B7 Play between two computer players.
=B7 Each player is to extend the abstract class ,,Player ", which is
available on the practical course web pages for the Download.
References
=B7 One can make Screenshots simply by pressing the key at the same
time ,,pressure/print screen "and/or <Alt> and ,,pressure/print
screen "(the screen and/or the active window copies as diagram into
the intermediate file, so that these can be inserted in Word over
Edit->Past as picture directly).
=B7 The aim for this program is to show as simple text edition as
shown in the example TicTacToe (see C++ program
simpleTicTacToe.cpp).
=B7 In the simplest case the computer player can make coincidental
courses (see C++ program zufallszahlen.cpp (RandomNumbers). A more
intelligent strategy for the computer player can be programmed
according to the mini max algorithm (e.g. see.
http://de.wikipedia.org/wiki/
http://en.wikipedia.org/wiki/Minimax_algorithm). An improved variant
for this algorithm is the alpha beta search (e.g. see
http://en.wikipedia.org/wiki/Alpha-Beta). Tag: red exclamation mark icon Tag: 266656
Packet split
Hi all,
I have a problem recieving data from a host machine. I m usiing socket
programing. I formed a packet on host machine.
When i run the application on the local machine (both server and client) I
reiceve all data and packets.
When i run the server on a remote machine i recieve less size data than
expected once a while.
I should recieve a packet size of 1118. sometime i recieve two packets with
the size of 342 and 746. I dont figure it out why i recieve like this.
Any help would be great.
Thanks,
thiru Tag: red exclamation mark icon Tag: 266654
Linker Warning
Hi !!! I am using Microsoft Visual C++ 8.0 compiler. I have precompiled
headers file "precomp.h" and "precomp.cpp". When I compile I have
always this warning "precomp.cpp: no public symbols found, archive
members will be inaccessible". I know that by other empty files is it
OK, but by precompiled headers file it is OK that I have empty source
file. What should I do, if I want to switch off the warning?
Thanks. Tag: red exclamation mark icon Tag: 266652
PeekNamedPipe not working!
I am using PeekNamedPipe on anonymous pipes. It always returns 0 in
lpBytesRead, lpTotalBytesAvail and lpBytesLeftThisMessage even if data
is written in pipe. I want to check if data is available to read,
before making a ReadFile call, so that it does not blocks. Is there
some other way? Tag: red exclamation mark icon Tag: 266644
How can i run an .exe on vista which i have designed on win2k3
Hi,
I have developed a VC++ program on win2k3 environment.
When i am running it on Vista then it is giving an error.
"Side by side configuration is not proper"
What it means?
Thanks inadvance for suggestion.
--Durgesh Tag: red exclamation mark icon Tag: 266640
non admin FlushFileBuffers for a volume
Hi All,
In our software we need to flush all the data on a removable device(disk
on key). The problem is that when user is non admin we can't obtain
handle to the volume using CreateFile cause of the insufficient
privileges. I'm looking for a work around to cause file/cache manager to
flush all the data.
Btw eject is not an option for us as after flushing we are doing some
operation via disk on keys firmware that cause it to show "private"
folders, if we do this without flush the data is lost on Win2k machines
where Performance check box is by default turned on on disk on keys.
Thanks in advance Tag: red exclamation mark icon Tag: 266638
Write text to, split, join, and page count tiffs
Ok, this has been asked over and over again....but i have to ask
because there has to be a better way (without spending $$). First
things first, I'm running many (thousands of) tif images through an
application I have been building. So far, i have used the
Image.GetFrameCount to get page counts and write strings on images,
split, and join using the graphics object. For anyone that has used
either of these, it is incredibly slow especially compared to some of
these 3rd party libraries that you can purchase for hundreds to
thousands of dollars....seems kind of pointless to spend more than $10
on what i need to use them for. I have used FreeImage from
SourceForge, and, compared to namely LeadTools, it is STILL slower for
getting page counts and I cant even do any drawing using the library.
What I am looking for is either a library or an example of how I can
perform these actions with speed as a must. I am primarily a C#
developer but can delve a little in C++. I am willing to do a little
C++ code, so if that helps with a solution please dont let that be a
limit. ANY help in any of these areas is much more appreciated than
you can imagine. Thank you in advance! Tag: red exclamation mark icon Tag: 266635
Question about hooking
Hi,
I'm trying to hook another application's window to check for WM_MOVE
messages. Does anyone know of any examples (that arent for keyboard and
mouse hooks)?
I suppose i want to do the same as SPY++, just for fewer messages!
Thankyou in expectation,
James Tag: red exclamation mark icon Tag: 266628
Convert TCHAR to integer!
Hello,
As I now know that const or not, either way the parameter is accepted in the
_ttoi() function.
On that note...
Please consider the following code:
===================================================
case WM_COMMAND:
if ((LOWORD(wParam) >= extnl_INT_INPUT_MVars[0].CW2_CV_ID) &&
(LOWORD(wParam) <= extnl_INT_INPUT_MVars[3].CW2_CV_ID) )
//Fetch function!
UpDateSimExtrnlInputs_INT(wParam, lParam, &io,
HWND_CW2_extnl_INT_INPUT_CV);
...other code ....
==================================================
===============================UpDateSimExtrnlInputs_INT()
void UpDateSimExtrnlInputs_INT(WPARAM wParam, LPARAM lParam, IO *io,
HWND HWND_CW2_extnl_INT_INPUT_CV[])
{
int k;
//TCHAR szBufferINPUT[] = _T("12345"); Tried it ! Gives error!
TCHAR szBufferINPUT[10]; //Declare 10 character array
SendMessage(
(HWND) lParam, WM_GETTEXT,
5, (LPARAM)szBufferINPUT ); //Get the text in the control
//The next line should convert the string buffer to an integer
k = _ttoi(szBufferINPUT); //This line gives the error!
}
=====================================================
Here is the error that I get:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_CW2.cpp(780):
error C3861: '_ttoi': identifier not found, even with argument-dependent
lookup
I have re-posted this question, and the fellows that answered the previous
post are very welcome to continue with it and I will more that willingly work
on all your feedback. I find the previous post had too many topics and I was
getting confused that's all! :)
I don't disagree with you Brian, hence, yes, gosh, Yes we are in trouble!
I know that the TEXT macro is defined in a few ways like as:
#define _T(x) __T(x)
and so that's where David got the following line:
TCHAR szBufferINPUT[] = _T("12345");
But I get an error on this...
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_CW2.cpp(768): error C3861: '_T': identifier not found, even with argument-dependent lookup
But you see that SendMessage() will get different text from different
controls. So:
TCHAR szBufferINPUT[] = _T("12345");
can't be so. The buffer has to be filled in with a new values everytime. And
I did try it if you look at the above code!
Anyways I still would appreciate some help on this topic!
Thankyou news groups!
--
Best regards
Robert
--
Best regards
Robert Tag: red exclamation mark icon Tag: 266627
Convert TCHAR to const char?
Hello,
I have the following sendMessage that returns text and is stored in a string
of TCHAR type.
==============================================
TCHAR szBufferINPUT[10];
SendMessage(
(HWND) lParam, WM_GETTEXT,
5, (LPARAM)szBufferINPUT );
==============================================
Now, I need to convert this text string to an integer type.... So I fugure
to go with the atoi function!
But the atoi takes in a const char!
I looked in many books for explanations on conversions from TCHAR to const
char.... ya right! Haven't found one!
So I searched the WIndows help and came up with this:
"Remarks
These functions convert a character string to a double-precision,
floating-point value (atof and _wtof), an integer value (atoi, _atoi64, _wtoi
and _wtoi64), or a long integer value (atol and _wtol). "
So I guess my choice would be atoi or _wtoi right?
in either case I getthe following errors respectively:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_CW2.cpp(773):
error C2664: '_wtoi' : cannot convert parameter 1 from 'TCHAR' to 'const
wchar_t *'
c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\XPPLC\WndProc_CW2.cpp(773):
error C2664: 'atoi' : cannot convert parameter 1 from 'TCHAR' to 'const char
*'
Can anyone show me what I need to do for this to work along with a breif
explaination so I can get one step closer to fully understand data types and
their conversions! A little discouraged although axious to learn!
All suggestions appreciated!
--
Kind regards
Robert Tag: red exclamation mark icon Tag: 266613
Typelib info for IPersistFile interface ?
Hi:
I need my atl object to implement the IPersistFile interface. Any of
you know where is the Typelib info (*.tlb,*.exe,*.dll,*.ocx,*.ocb file)
for that interface?
Upon OleView tool that interface is provided by ole32.dll, but that
file doesn't have that kind of info embedded.
Thanks in advance.
Regards. Tag: red exclamation mark icon Tag: 266612
Quick question!
Hello,
Say I have a break point on the following line of code:
=============================================
static TCHAR szBufferINPUT[10];
for(i=0;i<4;i++)
{
HWND_CW2_extnl_INT_INPUT_CV[i] = CreateWindow( TEXT ("edit"), TEXT("zero"),
WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_LEFT | ES_MULTILINE, extnl_INT_INPUT_MVars[i].ExtnlMVarLeft,
extnl_INT_INPUT_MVars[i].ExtnlMVarTop,
extnl_INT_INPUT_MVars[i].ExtnlMVarRight,
extnl_INT_INPUT_MVars[i].ExtnlMVarBottom,
hwnd,(HMENU)extnl_INT_INPUT_MVars[i].CW2_CV_ID,
((LPCREATESTRUCT) lParam)->hInstance,NULL);
}
===============================================
When the program execution stops at the line above and I view the locals
variables watch, the value of the handle returned from the above statement at
this point is 244842618. Obviously, I only look at the first control for
now... so at, say when i = 0.
So later in my code I click on the first edit control and I have another
break point in the code handling for this control as done so in the following
code:
=================================================
case WM_COMMAND:
if ((LOWORD(wParam) >= extnl_INT_INPUT_MVars[0].CW2_CV_ID) &&
(LOWORD(wParam) <= extnl_INT_INPUT_MVars[3].CW2_CV_ID) )
SendMessage( //***BREAKPOINT HERE***
(HWND) lParam,
EM_GETLINE,
0, (LPARAM) szBufferINPUT );
=================================================
why is it that if I put a break point at SendMessage() line above, the value
of lParam is not 244842618? It is 3212454 instead?
Isn't lParam the child control's handle? Atleast this is what I read! Okay,
okay... I actually read that it was the child Window handle! But isn't that
the same thing?
Why the different handle values?
And the second part of my question is that I am trying to retreive the value
from my edit control.... As you see as I create my edit controls I insert a
default value of "zero" in them!
Why is it that when I run the code above and when I put my cursor over the
szBufferINPUT in the following line of code I get "". Means it is reading
nothing when I expected a "zero" to be read?
SendMessage(
(HWND) lParam,
EM_GETLINE,
0, (LPARAM) szBufferINPUT );
===================================================
[2nd Part of my question]
Also, I have gone through this 6 months ago with some sympathetic news
groups fellows and it still gets the best of me because everytime I see this
I sort of generate a fear of it. But now that it is facing me one more time,
I shall persue more knowledge on it!
***DATA TYPES!***
Okay, lest try this again! If I may politely ask you to be patient, god
knows you all have! :)
***All the edit controls I have created can hold up to 4 characters max!
The help files for the EM_GETLINE message says:
"lParam
Pointer to the buffer that receives a copy of the line. Before sending the
message, set the first word of this buffer to the size, in TCHARs, of the
buffer. For ANSI text, this is the number of bytes; for Unicode text, this is
the number of characters. The size in the first word is overwritten by the
copied line."
But when we look at the prototype of this function it says that lParam
should take a
(LPARAM) or a (LPCTSTR) type right?
But LPCTSTR has been defined as so in the WINNT.H of the Windows files:
===============================================
typedef CONST WCHAR * LPCWCH, * PCWCH, * LPCWSTR, * PCWSTR
and then:
#ifdef UNICODE
....other type def's...
typedef LPCWSTR LPCTSTR
===============================================
So if I declare my string buffer in TCHARs as stipulated above!
static TCHAR szBufferINPUT[10]; //Space for 10 characters!
then how does the prototype parameter accept a TCHAR when it should accept a
LPCTSTR? Because as typedefed above, if LPCTSTR is defined as a LPCWSTR type
and further LPCWSTR is defined as a CONST WCHAR type so then, how is does
the CONST WCHAR type defined as a TCHAR type, which is what we need right?
Could this have something to do why I read "" instead of "zero" in the 1st
part of my question?
Sorry for the lenghty post!
All help appreciated.....
P.S. Sorry for the numerous postings, this month its like almost every line
I try, turns up to be a many hours snag!
--
Best regards
Roberto Tag: red exclamation mark icon Tag: 266605
thread
Is there any way to create a thread that does not begin by calling a
function?
I would basically like a thread that starts executing at the current
point in the program.
This would be similar to calling the Unix fork() function but for
threads.
It would help make my code much cleaner.
Thank you. Tag: red exclamation mark icon Tag: 266604
CBitmap - Load JPG
Hi there,
I'm using the CBitmap class to load images from file. At current I am
having to use the LoadImage method of User32.dll to load my images but
unfortunately it does not seem to support the loading of any other image
than BMP.
I was just wondering what the normal procedure for loading JPEG's, GIFS
etc into a CBitmap object usuall is?
Nick. Tag: red exclamation mark icon Tag: 266599
importing messages from outlook express
how we can import picture messages from outlook express using
dbxMessage in vc++? Tag: red exclamation mark icon Tag: 266595
What the....! is going on!
Hello,
This one I just had to post! It must be me again.... but I must know why!
Check this out:
====================================
case WM_COMMAND:
//IF EXIT BUTTON CLICKED THEN EXIT APPLICATION
if (LOWORD(wParam) == WindowButtonsCW2[0].MW_btC_ID)
DestroyWindow(hwnd); //End application
//UPDATE SIMULATED BOOLEAN INPUTS
else if ((LOWORD(wParam) >= ChkBoxes[0].MW_btC_ID) ||
(LOWORD(wParam) <= ChkBoxes[3].MW_btC_ID) )
UpdatingSimInputs_BOOL(lParam,&io);
//UPDATE SIMULATED INTEGER INPUTS
else if (LOWORD(wParam) == 150)
UpDateSimExtrnlInputs_INT(); //***IT NEVER COMES HERE!!!***
return 0;
==================================================
It never goes to the following line???????????????????????????
UpDateSimExtrnlInputs_INT();
The value of wParam is 16777366, which the LOWORD of this is 150!
I tried it with brackets and no brakets after the if's and else if's, and
same problem!
If I remove all (else if's) then it works, like this:
=============================================
case WM_COMMAND:
//UPDATE SIMULATED INTEGER INPUTS
if (LOWORD(wParam) == 150)
UpDateSimExtrnlInputs_INT(); //***NOW IT COMES HERE!!!***
return 0;
===============================================
This ought to be a good one, I tell ya! :-)
Allfeedback welcome !
Thanks!
--
Best regards
Robert Tag: red exclamation mark icon Tag: 266586
const std::map reference and __declspec property
Inside my class, I'm maintaining a private map like this:
std::map< unsigned long, AuthorizedDatabase > m_authorizedDatabases;
The idea is to expose this as a property and be able to reference
individual elements using a syntax like this:
AuthorizedDatabase db = x.AuthorizedDatabases[0x09000112];
Currently, I had a failed attempt at this using a property and an
accessor method:
const std::map< unsigned long, AuthorizedDatabase >&
GetAuthorizedDatabases() const;
__declspec( property( get=GetAuthorizedDatabases ) ) const std::map<
unsigned long, AuthorizedDatabase >& AuthorizedDatabases;
This obviously won't work because I'm returning a const map reference
and the operator[] is non-const because it can modify the map. I'd
rather not return a non-const reference that could be modified, and I'd
also like to avoid returning a complete copy of the map.
Is there any container class better suited to this that has an
operator[] that can be used on a const version of the object?
Alternatively, is there a better way to go about accomplishing this?
Thanks,
-Matthew Tag: red exclamation mark icon Tag: 266584
using tryparse
Hello everyone,
I've got a little problem, I'm programming in visual c++ and I try to
get back some numbers from a form using tryparse. It works perfectly on
my computer because the configuration is an english one. But on a
french configuration where the dot of floats is a comma it doesn't
work.
I mean it works with a comma but I would like to stay in an english
configuration with the dot.
Thanks for your help
--
ryo Tag: red exclamation mark icon Tag: 266578
customize setting for \t escape sequence
Hello,
I am using MSVC C++ .NET. I am trying to write a simple console program
using cout to display text to the console window. When I try to use the \t
escape sequence, it gives me 3 spaces. I would like it to give me 4 spaces.
How do I change this? Step by Step wallthrough or a link to a step by step
"dummy" proof walk through would be GREAT!
Thank you,
--
Geoff
glhart\\@\\hotmail.\\com Tag: red exclamation mark icon Tag: 266575
"edit" control is read only?
Hello,
I am using the edit class as I am creating a control as so:
==============================================
static HWND HWND1;
LRESULT xxx;
HWND1 = CreateWindow( TEXT ("edit"), TEXT("zero"),
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_MULTILINE, 10,10,50,30,
hwnd,(HMENU)800,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
//Set the control as non read only!
xxx = SendMessage(
(HWND) HWND1, // handle to destination control
(UINT) EM_SETREADONLY, // message ID
(WPARAM) false, // = (WPARAM) () wParam;
(LPARAM) 0); // = 0; not used, must be
zero );
===================================================
Can anyone tell me why the edit control created with CreateWindow appears as
read only. I don't see a flashing cursor in the control, nor can I type text
in it!
I know the above code is not much for you fellows to work with, however
before I spend 4 hours reducing my project to a few compilable lines, If I
may politely ask! I was just wondering if someone had this problem already
where its solution would be an obvious and simplistic one! If not well, just
let me know and its no problem, I will crunch it down to more of an
analysable and compilable size!
Also, xxx reurns a 1, apparently if the function fails, it should return a
0. So I guess my control is not set as read only! But why is it still read
only?
My code is 99% the same as the POPPAD1.C from M. Petzold's hand book! P.396.
The only difference is that as a whole, my application is much larger and I
am doing this on a child window where as he is doing it on the main wndProc
window. I don't think this should make a difference.... But I could be wrong!
All feedback for this is appreciated.
Wish you all a nice day! :)
--
Best regards
Robert Tag: red exclamation mark icon Tag: 266560
Are std::list and std::map safe to export?
Is it safe to export a class containing public std::list and std::map
members and suppress the C4251 warning?
I've seen mixed results in my search for an answer. Some say to
explicitly export an instantiation
(http://support.microsoft.com/kb/q168958/) for vectors, but the
remaining STL classes cannot be exported. Others have suggested
disabling the warning or explicitly exporting instantiations of all
related STL classes
(http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html).
What's the general consensus on using the various STL classes from
across DLL boundaries?
Thanks,
-Matthew Tag: red exclamation mark icon Tag: 266558
returning a char buffer from com object
I have a COM object with a method:
STDMETHODIMP CIMyAPI::GetValueA(CHAR * string, UINT * nMaxLen)
{
*nMaxLen = sprintf_s(string, *nMaxLen, "Hello");
return S_OK;
}
but, when I call this method from a class that instantiates my COM
object like this:
SomeFunction()
{
IIMyAPIPtr pIMyAPI;
//...
CHAR stringA[32] = {'\0'};
UINT len = sizeof(stringA);
hr = pIMyAPI->GetValueA(stringA, &len);
//...
}
stringA just contains "H" and not "Hello".
So, how do I get a buffer in and out of a COM object?
-PaulH
If it helps, my IDL definition for this function is:
[id(4), helpstring("method GetValueA")] HRESULT GetValueA([out] CHAR *
string, [in,out] UINT * nMaxLen); Tag: red exclamation mark icon Tag: 266549
Kill debug for single module
Hi,
I am having a problem with a certain DLL (thats basically littered with
badly placed interupts / breakpoints) and I would like to disable the
debugger picking them up for just the one DLL.
Is this possible? if so would someone explain to me how to acomplish this in
Visual Studio 2005.
Cheers
--
- Mark Randall
http://www.temporal-solutions.co.uk
"We're Systems and Networks..."
"It's our job to know..." Tag: red exclamation mark icon Tag: 266547
Slow function
I'm creating an application that will be calling a function that
takes about a minute or so to process some data. What is the standard
procedure for doing something like this in Windows? I don't want the
Graphical User Interface to freeze up or anything like that.
I'm guessing that I can create a new thread to call the function
using CreateThread and then pop up a modal dialog box telling the user
to wait. Or is there a better way of doing this?
Thank you. Tag: red exclamation mark icon Tag: 266541
Link problem
I recently moved a project from VS6 to VS2005 and am now receiving:
libguide.lib(z_Windows_NT-586_util.obj) : error LNK2001: unresolved external
symbol __iob
How can I resolve this?
Thanks,
Drew Tag: red exclamation mark icon Tag: 266538
creating a .tlb to for a COM DLL
I'm working on a COM object DLL with VS2005, it compiles fine with no
errors or warnings and registers okay, but no .tlb file is created with
it.
When I go to import it with a test app (#import "mydll.dll"), I get the
compiler error
"fatal error C1083: Cannot open type library file: 'mydll.dll': Error
loading type library/DLL."
I assume it's because there's no .tlb associated with it???
Because midl is build in to VS2005, I figured everything would "just
work". I am using the /tlb "mydll.tlb" option and I have all the
error-checking options turned on.
Is there something else I need to do? Is there an obvious thing I'm
doing wrong, perhaps? I did notice that midl, on warning lv 4 only,
does have 32 warnings about "warning MIDL2111 : identifier length
exceeds 31 characters :". Would that keep the .tlb from forming?
Thanks,
PaulH Tag: red exclamation mark icon Tag: 266531
multifile program organization
All my previous programs have had the classes and main() in the same
.cpp file. For the first time, I have separated the classes into
header (.h) and source (.cpp) files. My general question is: if I want
to have two separate application programs (i.e. main() ) that will use
these classes, what is the standard way of organizing the various
files? Should I (1) add a new workspace to the original project
folder, thereby, having two workspaces and their respective files in
the same project folder? (2) add a new project folder to the original
folder? (3) put the class files in a separate folder, then have two
separate project folders for the two different application programs?
I would just like to know what the standard practice is.
(I use MS VC 6.0.) Tag: red exclamation mark icon Tag: 266526
Ping code featuring IPv6
I am developing a mfc software who is in the need of pinging IPv4 and
IPv6 addresses, but the code I'm working with only has the capability
of pinging IPv4 addresses.
There are some software requirements making it harder, the software is
standalone, requiring no installation. It should also be able to run it
even though the current user isn't an administartor on the computer.
Has anyone any experiance in this topic or could point me in the right
direction?
/Mattias Tag: red exclamation mark icon Tag: 266525
On runtimes, string wrapping and vs7 / vs8
Hi all.
We have a dll with an api that use std::strings for a bunch of things.
It worked fine as long as you match the application & library runtimes.
Unfortunately, not all of our customers can match the runtimes due to
other restrictions such as other dll:s, mfc stuff etc. So we made an
effort to wrap the stuff we needed to wrap, ensuring that
heap-allocated things whould get allocated / deallocated in the same
heap. With VS2003, it worked like a charm. The developers were happy,
tech support was even more happy, and the customers were not
complaining as much as they used to.
Then came VS2005, and our wrapping solution doesn't work anymore. The
problems occur when you use a release-mode dll compiled with VS2003
with a debug-mode application compiled with VS2005. Now, I can imagine
that our solution really is pushing it a bit, but I'd love to get some
details on why it doesn't work.
The solution relies on that the inline functions of the library objects
gets compiled with the application code, and the objects will have some
functions compiled with VS2003 and some with VS2005. My guess would be
that there are some differences in object layout between VS2003 and
debug mode VS2005, since the errors we get are heap corruptions and
they can be triggered by using inlined setters on other object members.
That is, I can get a heap corruption from a string destructor in an
object without ever touching that string, but having touched other
members in that object. In the below sample, I'd get this from the
destructor on SampleLibClass::stringThing after a testcase that only
use the nonWrappedSetter.
So, a sketch of our solution (API_DECL is the standard dllimport /
dllexport macro):
// A wrapper for std::string
class StringH {
public:
// application side interface
API_DECL StringH();
API_DECL ~StringH();
API_DECL const char* c_str() const;
API_DECL count_t length() const;
// library side interface
void init(const char *str);
void init(const std::string& str);
private:
// defined in the cpp-file as:
// struct StringH::Impl : public string { ... }
struct Impl;
Impl* pImpl;
StringH(const StringH&) {}
};
// this is how we use it in the library
class SampleLibClass {
public:
// ... some stuff ...
void setStringThing(const std::string &str) {
setStringThing_(str.c_str());
}
const std::string getStringThing() const {
StringH sh;
getStringThing_(sh);
return std::string(sh.c_str());
}
API_DECL int nonWrappedSetter(int prm) { nonWrappedInt = prm; }
private:
API_DECL void setStringThing_(const char *cstr);
API_DECL void getStringThing_(StringH &sh) const;
std::string stringThing;
int nonWrappedInt;
// ... more stuff ...
}
So... Does the object layout differ? Is this an ok-ish solution, or are
we violating a bunch of things and we were simply lucky that it worked
with VS2003 and the different runtimes there? Would it work if we
removed all inlined non-wrapped setters and getters, moving their
implementations to the sourcefile instead?
Any hints appreciated! Our other option would be to scrap the strings,
and vector<string> that we use and use const char* and const char*
arrays instead, perhaps combined with a application side only wrapper
that gets fully compiled with the application compiler.
Many thanks,
/Niklas Tag: red exclamation mark icon Tag: 266516
VC++ 6.0 Linker query.
The functions rijndaelEncrypt and rijndaelKeySeupEnc are clearly defined in
rijndael-alg-fst.c. The compiling goes without any eror, but the linking
throws up errors. I tried fiddling with the options in the linker with no
luck. What am I missing here? I have used Bloodshed till now and compiling
and building worked fine this way.
Below is my build report:
Deleting intermediate files and output files for project 'sfx - Win32
Debug'.
--------------------Configuration: sfx - Win32 Debug--------------------
Compiling resources...
Compiling...
rijndael-alg-fst.c
sfx.cpp
Linking...
sfx.obj : error LNK2001: unresolved external symbol "void __cdecl
rijndaelEncrypt(unsigned int const * const,int,unsigned char const *
const,unsigned char * const)" (?rijndaelEncrypt@@YAXQBIHQBEQAE@Z)
sfx.obj : error LNK2001: unresolved external symbol "int __cdecl
rijndaelKeySetupEnc(unsigned int * const,unsigned char const * const,int)"
(?rijndaelKeySetupEnc@@YAHQAIQBEH@Z)
Debug/sfx.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
sfx.exe - 3 error(s)
-- Tag: red exclamation mark icon Tag: 266504
Converting FILETIME into two DWORDS
Hi,
i want to extract date and time from a filetime structure into two dwords in
the same way in which NTFS store the file creation, modification and access
date.
Can anybody tell me how to do this.
Thanks. Tag: red exclamation mark icon Tag: 266503
Calculate angle between two lines
hello,
i want to calculate angle between two lines considering all the
possiblities (acute, obtuse and parallel to Y-axis).
If any one can tell me how to proceed with this (I have drawn these
lines using MFC classes and want to display the angle.)
thank you. Tag: red exclamation mark icon Tag: 266497
Why crash ?
Hi Experts:
I have a a few lines of code and it crashes everytime at the line marked
below. The code just converts a string into upper case string. Any help is
appriciated.
Thanks In Advance!
Polaris
-----------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
int main (int argc, wchar_t *argv[])
{
wchar_t *str = L"abcdefghijklmn";
// transfer str to upper case
wstring sUpper;
int len = (int) wcslen (str);
for (int i=0; i<=len; i++)
sUpper[i] = towupper (str[i]); // crash here when i = 11
return 0;
} Tag: red exclamation mark icon Tag: 266487
Buttons Pop up [Part-2]
Hello,
If you are not familiar with the question of this post, you can get a quick
glimps at its description at the first part of this post called "Buttons Pop
up!"
The reason I started a new post on the same question is so I don't clutter
up the previous post! So here is a clean start!
I have taken the advice of a news groups fellow to strip down my program so
I can isolate the problem, and I did, however the situation still persists. I
call this a "situation" because at this point, I don't know if the problem I
am facing is normal when creating a windows with CreateWindow();
In short, I now have two (2) windows, and therefore it means I have 2
WndProc's,
WndProc.cpp and WndProc_CW2.cpp which we will call Window#1 and Window #2
respectively. I also have a Main.cpp for the good old Windows message pump!
The first window is based on WndProc.cpp with one(1) button which opens
a child window based on WndProc_CW2.pp. I also have an exit button on the
first window which is of no relevance to this issue.
So when I click on a button on window#1, it opens window#2, and do you agree
that some space on the second window is right above some buttons of the
first window right underneath.... right! (lets call this space "space X"). So
space
X is the space that is on my second window where it aligns directly with the
space containing a button on the opened window #1 which is right behind it.
If I click on some of its space X, well, the button from the underneath
window, pops up in the top window(window #2) currently open. ??? I can even
move window#2 around and this newly poped up button stays in the client area!
Does anyone have any I deas of what could be going on !
Here is a watered down skeleton of the app, it contains 6 very small files!
Here's the code:
-Excuse me if its a long post....You would not believe how much code I
removed... however if you feel its still too long, its no problem, let me
know and I will repost a shorter version. Although, it only looks long
however its all basic routine code that is very common in every Windows
code. ============================================Main.h
//DECLARE CALLBACKS!
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WndProc_CW2 (HWND, UINT, WPARAM, LPARAM);
==================================================
============================================Main.cpp
#include <windows.h>
#include "MAIN.h"
static TCHAR *szMW_Name = TEXT ("MAIN APPLICATION 1");
//Name of window
static TCHAR szMW_ClassName[] = TEXT ("MW");
//Class name of window
//Declaration of Class name for Window based on WndProc_CW2
static TCHAR szCW2_ClassName[] = TEXT("CW2");
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInnstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
//-MAIN WINDOW CONFIGURATION based on WndProc
wndclass.style = CS_HREDRAW |CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szMW_ClassName;
//-REGISTRATION
RegisterClass (&wndclass);
//-CONFIGURATION -CHILD WINDOW #2
wndclass.lpfnWndProc = WndProc_CW2;
wndclass.hIcon = LoadIcon (NULL, IDI_EXCLAMATION);
wndclass.hIcon = NULL;
wndclass.lpszClassName = szCW2_ClassName;
//-REGISTRATION
RegisterClass(&wndclass);
//-CREATE MAIN APPLICATION WINDOW
hwnd = CreateWindow (szMW_ClassName,szMW_Name,
WS_OVERLAPPEDWINDOW ,
20, 20, 750, 550,NULL,NULL, hInstance,
NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow (hwnd);
//-WINDOWS MESSAGE LOOP
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
===================================================
==========================================WndPro.h
struct hdMW_WindowButtonsTAG
{
int iCTL_idx;
TCHAR *szMW_btC_Name;
int MW_btC_RectLeft;
int MW_btC_RectTop;
int MW_btC_RectRight;
int MW_btC_RectBottom;
int MW_btC_ID;
};
===================================================
==========================================WndProc.cpp
#include <windows.h>
#include "WndProc.h"
#define CW2_ID 2
static TCHAR *szCW2_Name = TEXT("Programming GUI");
//Child window title bar name
extern TCHAR szCW2_ClassName[] = TEXT("CW2");
//Child window class name . This is declared as extern because I need the
class name as a parameter for registration of the window in Main.cpp also.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
//MAIN WINDOW CONTROL PROPERTIES
hdMW_WindowButtonsTAG WindowButtons[] =
{
1,TEXT("< EXIT >"),650,450,80,40,1,
2,TEXT("< GUI >"),200,30,180,30,2,
};
static HWND hdCWdws[1];
static HWND hdMW_WindowButtons[2]; //Main window buttons
int i;
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_CREATE:
hdc = GetDC(hwnd);
//MAIN WINDOW BUTTON CONTROLS
for(i=0;i<2;i++)
{
hdMW_WindowButtons[i] = CreateWindow( TEXT
("button"),WindowButtons[i].szMW_btC_Name,
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON ,
WindowButtons[i].MW_btC_RectLeft,
WindowButtons[i].MW_btC_RectTop,
WindowButtons[i].MW_btC_RectRight,
WindowButtons[i].MW_btC_RectBottom,
hwnd,(HMENU)WindowButtons[i].MW_btC_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
}
ReleaseDC(hwnd,hdc);
return 0;
case WM_COMMAND:
//IF EXIT BUTTON CLICKED THEN EXIT APPLICATION
if (LOWORD(wParam) == WindowButtons[0].MW_btC_ID)
{
DestroyWindow(hwnd); //End application
}
//CREATE CHILD WINDOW #2 WHEN BUTTON #2 PRESSED
else if (LOWORD(wParam) == WindowButtons[1].MW_btC_ID)
hdCWdws[1] = CreateWindow(
szCW2_ClassName,szCW2_Name,
WS_CHILD | WS_CAPTION | WS_SYSMENU,
10, 10, 700, 450,hwnd,(HMENU)CW2_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
//SHOW CHILD WINDOW #1
ShowWindow(hdCWdws[1],SW_SHOW);
return 0;
case WM_DESTROY:
//CLEAR ALL OBJECTS
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
==================================================
===========================================WndPro_CW2.h
struct hdCW2_WindowButtonsTAG
{
int iCTL_idx;
TCHAR *szMW_btC_Name;
int MW_btC_RectLeft;
int MW_btC_RectTop;
int MW_btC_RectRight;
int MW_btC_RectBottom;
int MW_btC_ID;
};
===================================================
========================================WndProc_CW2.cpp
#include <windows.h>
#include "WndProc_CW2.h"
LRESULT CALLBACK WndProc_CW2(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
//MAIN WINDOW CONTROL PROPERTIES
hdCW2_WindowButtonsTAG WindowButtonsCW2[] =
{
1,TEXT("< EXIT >"),580,350,80,40,1,
};
static HWND hdCW2_WindowButtons[1];
int i;
HDC hdc;
switch(message)
{
case WM_SIZE:
SetFocus(hwnd);
return 0;
case WM_CREATE:
hdc = GetDC(hwnd);
//MAIN WINDOW BUTTON CONTROLS
for(i=0;i<1;i++)
{
hdCW2_WindowButtons[i] = CreateWindow( TEXT
("button"),WindowButtonsCW2[i].szMW_btC_Name,
WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON ,
WindowButtonsCW2[i].MW_btC_RectLeft,
WindowButtonsCW2[i].MW_btC_RectTop,
WindowButtonsCW2[i].MW_btC_RectRight,
WindowButtonsCW2[i].MW_btC_RectBottom,
hwnd,(HMENU)WindowButtonsCW2[i].MW_btC_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
}
ReleaseDC(hwnd,hdc);
return 0;
case WM_COMMAND:
//IF EXIT BUTTON CLICKED THEN EXIT APPLICATION
if (LOWORD(wParam) == WindowButtonsCW2[0].MW_btC_ID)
{
DestroyWindow(hwnd); //End application
}
return 0;
case WM_CLOSE: //Handler to do code on close
break;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
====================================================
Agian, excuse the lenghty post.....
So, basically, I always get the button to pop up from the bottom window on
to the top window when clicked on space X!
I am as we speak, trying to troubleshoot this, I surely appreciate any input
from the news groups!
Thankyou all!
--
Best regards
Robert Tag: red exclamation mark icon Tag: 266476
Microsoft Agent
I'm trying to add a Microsoft Agent character (the wizard) to my app.
I placed a Microsoft Agent 2.0 ActiveX control on my MFC dialog. Then
I added a variable for it. It created a class called CControl1, but it
has no functions. Anyone know what I'm doing wrong?
If I do this with a web browser control, the class it creates has
plenty of useful functions. Tag: red exclamation mark icon Tag: 266474
CDC::SelectBitmap method
Hi there,
For some reason I cannot seem to find any information on this method in
the VS.NET 2005 documentation. I am currently having problems drawing a
bitmap to a DC and most examples on the net that I come across suggest using
the SelectObject method of a CDC object. My CDC object doesn't even have a
SelectObject method, so I must have something different...
if(m_bitmap!=NULL)
{
CSize pSizSize;
m_bitmap.GetSize(pSizSize);
CDC pCDCBitmap;
pCDCBitmap.CreateCompatibleDC(dc);
CBitmap pBmpBitmap = pCDCBitmap.SelectBitmap(m_bitmap);
dc.BitBlt(rc.left, rc.top, pSizSize.cx, pSizSize.cy, pCDCBitmap, 0, 0,
SRCCOPY);
pCDCBitmap.SelectBitmap(pBmpBitmap);
pCDCBitmap.DeleteDC();
}
My code is very simple at the moment, but the bitmap is not appearing.
I have tried calling the global SelectObject method but this produces the
same result. The image has definitely been initialised in m_bitmap, and the
BitBlt method is reached. Any ideas on what I could be doing wrongly?
Nick. Tag: red exclamation mark icon Tag: 266466
How can I validate file location in VC++ 6.0?
Hi All,
If I am taking input and output location from user in file handling
application, how can I validate that given location exist or not using
VC6 ? That is user is giving right directories or not. If the location
read only extra. Tag: red exclamation mark icon Tag: 266464
WaitForSingleObject on Console not working???
How can I know if there is input or not from keyboard in console
application? I want to flush buffer to screen every second.
In Unix, select( ) with stdin and timeout can work well( return timeout
every second ), but in Windows, stdin is NOTSOCK, hence select won't
work.
In Windows, WaitForSingleObject( stdinHandle, 1000 ) will return
"WAIT_OBJECT_0" when waiting for input.
How come the following always goes into "WAIT_OBJECT_0"?
What could I do? Is there any way to use select( ) in Windows with
stdin?
Thanks!
#include <windows.h>
#include <stdio.h>
int main()
{
printf("->");
static HANDLE stdinHandle;
// Get the IO handles
// getc(stdin);
stdinHandle = GetStdHandle(STD_INPUT_HANDLE);
DWORD rc = WaitForSingleObject(stdinHandle, 1000);
if( rc == WAIT_TIMEOUT )
{
printf("Timeout...");
}
else if( rc == WAIT_ABANDONED )
{
printf("WAIT_ABANDONED");
}
else if( rc == WAIT_OBJECT_0 ) // Always go into this branch, why???
{
printf("WAIT_OBJECT_0");
}
else if( rc == WAIT_FAILED )
{
printf("Error:%d.", GetLastError());
}
return 0;
} Tag: red exclamation mark icon Tag: 266457
pin_ptr question
Given a String^ I want a pinned __wchar_t* with a null terminator.
So far, I have this:
static __wchar_t% StringToPChar(String^ Str) {
int len = Str->Length;
array<__wchar_t>^res = gcnew array<__wchar_t>(len + 1);
Str->CopyTo(0, res, 0, len);
res[len] = 0;
return res[0];
}
//managed wrapper
TC_INT32 Foo(String^ Str, TC_INT32 *Length) {
pin_ptr<__wchar_t> p = &StringToPChar(Str); //&&&
return _Foo(p, Length);
}
1. Does //&&& pin the entire array?
2. Is there better (more efficient) way of doing this? Something in the
marshalling classes maybe?
--
Martin Tag: red exclamation mark icon Tag: 266456
Add additional menu item to edit control's context menu
You should be familiar with the context menu of the edit control; Undo,
Cut, Copy, Paste, Delete.
Is it possible to add aditional custom item to this menu? Like Windows
Explorer and Internet Explorer context menus? If there is a way, please
let me know. Thanks. Tag: red exclamation mark icon Tag: 266454
Button pops up!
Hello,
The weirdest thing and I don't know how I will explain this! None the less I
will try!
I have three (3) windows, and therefore it means I have 3 winProc's.
The first window is the main window with two(2) buttons which each open
their respective window. So, button#1 opens window #2 and button #2 opens
window #3. (Window#1 is the main window with the two buttons!)
So when I open the 2nd window by clicking on the first button, you do agree
that some space on the second window is right above some buttons of the main
window right underneath.... right! (lets call this space "space X"). So space
X is the space that is on my second window where it aligns directly with the
space containing a button on the opened main window right behind it.
If I click on space X in the 2nd window, nothing happens and that's what we
all expect right!
However, when I open the 3rd window and click on some of its space X, well,
the button from the underneath window, pops up in the top window currently
open. ???
I unfortunately have done a huge re-structuring of my code and obviously,
there is something I left out!
Does anyone have any I deas of what could be going on !
I cannot really post the whole program, but I can post some fragments of
code that are directly related to the window#3 stipulated above:
============================================Main
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInnstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW |CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szMW_ClassName;
RegisterClass (&wndclass);
///////////////////////////////////////////////////////////////////////
//-CHILD WINDOW #1 //
//////////////////////////
wndclass.lpfnWndProc = WndProc_CW1;
wndclass.hIcon = LoadIcon (NULL, IDI_EXCLAMATION);
wndclass.hIcon = NULL;
wndclass.lpszClassName = szCW1_ClassName;
RegisterClass(&wndclass); //(RS232 Interface)
///////////////////////////////////////////////////////////////////////
//-CHILD WINDOW #2 //
//////////////////////////
//-CONFIGURATION
wndclass.lpfnWndProc = WndProc_CW2;
wndclass.hIcon = LoadIcon (NULL, IDI_EXCLAMATION);
wndclass.hIcon = NULL;
wndclass.lpszClassName = szCW2_ClassName;
RegisterClass(&wndclass); //Programming GUI
//CREATE MAIN WINDOW
hwnd = CreateWindow (szMW_ClassName,szMW_Name,
WS_OVERLAPPEDWINDOW ,
20, 20, 750, 550,NULL,NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0)) //Window's queue loop
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
====================================================
//Next is the cpp file that opens Window #3
======================================WinProc
... other code ...
case WM_COMMAND:
//IF EXIT BUTTON CLICKED THEN EXIT APPLICATION
if (LOWORD(wParam) == WindowButtons[0].MW_btC_ID)
{
DestroyWindow(hwnd); //End application
}
//CREATE CHILD WINDOW #3 WHEN BUTTON #2 PRESSED
else if (LOWORD(wParam) == WindowButtons[2].MW_btC_ID)
hdCWdws[2] = CreateWindow(
szCW2_ClassName,szCW2_Name,
WS_CHILD | WS_CAPTION | WS_SYSMENU,
10, 10, 700, 450,hwnd,(HMENU)CW2_ID,
(HINSTANCE) GetWindowLong(hwnd,GWL_HINSTANCE),NULL);
//SHOW CHILD WINDOW #3
ShowWindow(hdCWdws[2],SW_SHOW);
... othe r code...
==================================================
All ideas appreciated!
--
Best regards
Robert Tag: red exclamation mark icon Tag: 266446
exceptions
Is there any way to make the standard functions throw exceptions
instead of just passing back errors via return values?
This would make life much easier. Tag: red exclamation mark icon Tag: 266445
displaying a FILETIME
Is there a good function for displaying a FILETIME as a string?
I can try to convert to SYSTEMTIME using FileTimeToSystemTime and then
do GetDateFormat/GetTimeFormat, but it fails for large values of the
FILETIME. Tag: red exclamation mark icon Tag: 266444
x64 malloc > 2Gb
Hi,
I am running Visual Studio 2005, building a 64-bit application on a Windows
XP x64 computer with 8GB of memory.
However, whenever I try to malloc more than 2GB in a single malloc call, I
fail (null pointer is returned). I am linking with /LARGEADDRESSAWARE, but
this does not seem to be sufficient.
Are there specific compiler and linker flags I should set so that I can
allocate more than 2GB in a single malloc call?
Thanks. Tag: red exclamation mark icon Tag: 266441
cast error after compiling xerces.lib /komische TypeCast-fehler
Hello Newsgroup,
I want to build xerces.lib (actually dynamical, but as there are many linker
errors using the dll, the static .lib version)
ich möchte die xercesc-lib erstellen.
eigentlich die dynamische, aber da ich damit eine reihe von linkerprobleme
erhalten habe, nun die statische version.
After compiling I got the following errors:
dort bekomme ich beim erstellen mittlerweile (nur noch) die fehler:
1.
com\XMLDOMDocument.cpp(1461) : error C2664: '_wfopen': Konvertierung des
Paramet
ers 2 von 'const char [3]' in 'const wchar_t *' nicht möglich
Die Typen, auf die verwiesen wird, sind nicht verknüpft; die
Konvertieru
ng erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C-
oder Funktionsformat
in der entsprechenden Zeile von com\XMLDOMDocument.cpp steht:
FILE* fp = _tfopen(file, "wt");
2.
com\XMLHTTPRequest.cpp(885) : error C2664: 'SysAllocStringByteLen':
Konvertierun
g des Parameters 1 von 'TCHAR *' in 'LPCSTR' nicht möglich
Die Typen, auf die verwiesen wird, sind nicht verknüpft; die
Konvertieru
ng erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C-
oder
Funktionsformat.
in com\XMLHTTPRequest.cpp(885) steht:
*pVal = SysAllocStringByteLen(psz,m_lResponseBodyLength);
does anybody know how I can get it running?
weiß jemand, wie ich die wegbekomme?
I use MS SDK with MS Visual C++ 2005 Express Edition.
(I have qt-win-opensource-src-4.1.1 installed so that I can compile by
typing qmake, nmake as there is a corresponding .pro-file for xerces)
thx
mh Tag: red exclamation mark icon Tag: 266435
Hi,
Where I can find "red exclamation mark" icon, I was looking for this in
few dll's but failed?