|
See Here[^] or here[^]
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
|
|
Hi,
I am declaring some global variable which i need to use in many .cpp files in the project. Can anyone tell me which is the best place to declare global variable.
Anurag Gandhi.
|
|
|
|
|
declare in .h file and using #include "xxx.h" at cpp files.
|
|
|
|
|
Thanks
Will .cpp file work? because i want some initialization also at the time of declaration.
Anurag Gandhi.
|
|
|
|
|
Anurag Gandhi wrote: Will .cpp file work?
Not by itself. As you are not including a .CPP (You are not, are you?), no other code chunks would know about your global.
Anurag Gandhi wrote: because i want some initialization also at the time of declaration.
Sufficiently recent compilers allow static constants to be initialized in the .h.
If not, you declare in the .H you include everywhere, and define ONCE in a .CPP
Failure is not an option - it's built right in.
|
|
|
|
|
No, Don't put your global in a .h file unless it is a static inside a class. If it's a straight global at file scope you will get a different copy in every compilation unit (.cpp file) that includes the header, not a global variable at all!
Instead put the global in one .cpp file and then declare it as extern in any other where you want to use it, this is the old fashioned 'C' way but it still works.
#include "stdafx.h"<br />
int g_MyGlobal = 5;<br />
#include "stdafx.h"<br />
extern int g_Myglobal;<br />
This is considered very naughty these days as globals are bad Objects . You could consider using a Singleton pattern class instance or static class members for this sort of data.;)
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have done it as follows:
Stdafx.cpp
//...
CMyDoc* m_pDoc = NULL;
And then:
CMyView::OnInitialUpdate ()
{
extern CMyDoc* m_pDoc;
m_pDoc = GetDocument ();
}
Then you can use the reference to the ACTUAL document from everywhere, putting the "extern CMyDoc* m_pDoc" anywhere (CObject derived, Dialogs, CFormViews...).
For me it works, so I think it can be used with other type of variables.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I draged and droped an added registered activex control FPCapX on simple dialog in dialog based application used to display image from hardware attached.
When I start using any of its method which interact with hardware ,it gives this assert in debug mode,and in release mode it simply does not work.Control works very simply in VB applications. Actually each of this methods internally calls InvokeHelper function where the assert comes. When I searched on google about bug I found that
Activex Control is not initialised. Can anyone help on this please.
In google search only one relevant article comes Actually in that article one is trying to set values to activex control before its dialog gets initialised. but I am trying to use capture mwthod of activex far after dialog is loaded and when user clicks button capture. One more point i want to tell you, if instead of drag and drop from control toolbar if I create control using create function of it,it doesnot give assertion but it simply does nothing
|| ART OF LIVING ||
|
|
|
|
|
I posted a question to support at Bioenable about this - I hope they come back with an answer
'g'
|
|
|
|
|
this is the reply I received from Bioenabletech .. I suggest if you are a bona fide user of their software you take the issue up with them (they seem more interested in sales than support)
>>>
Dear Mr. Garth,
This is with reference to your requirement, The same can be achieve with our
enBSP SDK. The OCX control details will offer you a complete details about
the use and integration. In addition to that, BioEnable support Engg will
help you to integrating the same with our OCX control.
Cost: USD1580*
Anticipating your reply soon.
Thanks with Regards
Manojit Saha[ Sr. Sales Manager]
BioEnable Technologies Pvt. Ltd.
[ An ISO9001:2000 company]
103 Green Terrace, Koregaon Park, Pune-411001
09326170550, Fax:020-30523540, chat: mkt_bio@yahoo... manojit17@skype.com
Logistic : Sanjay/Gupte[ 9326170551-3]
|
|
|
|
|
Hi
Is there a way to change the title bar of MDI?
Thanks.
|
|
|
|
|
Aint wrote: change the title bar of MDI?
change title bar to what?
nave
|
|
|
|
|
change the title of the title bar.
|
|
|
|
|
AfxGetMainWnd()->SetWindowText( "New title" );
nave
|
|
|
|
|
I'm trying to write a client for a Windows CE 4.2 .NET device to use Bluetooth.
I'm getting a WSAEFAULT error (10014) on bind, does anyone know why this is?
The official documentation claims that its a bad pointer or too small of size. The conversion to SOCKADDR* (16bytes) is for winsock backwards compatablity, and the type SOCKADDR_BTH is 32bytes, thus the need for the the addr length in the third parameter.
WinMain
//
UINT Bluetooth_Message = RegisterWindowMessage(TEXT("BT_MSG"));
SendMessage(HWND_BROADCAST, Bluetooth_Message, 1, 0);
Sleep(1000);
printf("Bluetooth On\n");
WORD wVersionRequested = 0x202;
WSADATA m_data;
if (0 == ::WSAStartup(wVersionRequested, &m_data))
{
SOCKET s = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
DWORD lastError = ::GetLastError();
if (s == INVALID_SOCKET)
{
printf("Failed to get bluetooth socket! %s\n", GetLastErrorMessage(lastError));
exit(1);
}
printf(" socket Call completed: [0x%x] with ws: %d:%d\n", s, HIBYTE(m_data.wVersion), LOBYTE(m_data.wVersion));
SOCKADDR_BTH address= { 0 };
ZeroMemory(&address,sizeof(SOCKADDR_BTH));
address.addressFamily= AF_BTH;
address.btAddr= 0x0;
address.port= BT_PORT_ANY;
// address.serviceClassId= 0l;
SOCKADDR * pAddr=(SOCKADDR*)&address;
int nAddressSize= sizeof(SOCKADDR_BTH);
if (SOCKET_ERROR == bind(s, (const sockaddr*) &address, nAddressSize))
{
printf("Error with bind:\r\nWSAERROR: %d\n", WSAGetLastError());
printf("Sizes: SKB > %d", sizeof(SOCKADDR_BTH));
printf(" %d <adr ",="" sizeof(address));
="" printf("="" ska="" %d",="" sizeof(sockaddr));
="" %d\n",="" printf("\t="" saa="" %d="" naddrsize="" sizeof(*paddr),="" naddresssize);
="" printf("skabth:="" %u="" %l\n"="" ,="" address.addressfamily,="" address.port,="" address.btaddr);
=""
sleep(3000);
="" return="" -1;
="" }
this="" returns:
connected="" [1],="" 2;2
error="" with="" bind\r\nwsaerror:="" 10014
sizes="" skb="" 32="" addr="" ...="" naddresssize="" 32
...
i'm="" following="" the="" documentation="" (http:="" msdn2.microsoft.com="" en-us="" library="" ms863315.aspx)="" does="" anyone="" know="" how="" or="" why="" i'm="" getting="" this="" error?="" right="" now="" stuck="" on="" that="" problem="" because="" i="" can't="" tell="" it="" to="" listen="" without="" a="" bind.
=""
<div="" class="ForumSig">-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
I can't seem to see anything wrong except it looks to me like the size of a SOCKADDR_BTH should
be 30, not 32.
...
#include <pshpack1.h>
...
typedef struct _SOCKADDR_BTH
{
USHORT addressFamily;
BTH_ADDR btAddr;
GUID serviceClassId;
ULONG port;
} SOCKADDR_BTH, *PSOCKADDR_BTH;
Am I calculating that length wrong?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yep, structs are aligned 4bytes .... But I have tried using thirty in the length argument and it didn't make a difference. Although I can go up to sizeof(SOCKADDR_BTH)+8 that and after I'll get a Winsock error 10049.
-Steven Hicks CPACodeProjectAddict
|
|
|
|
|
(Steven Hicks)n+1 wrote: Yep, structs are aligned 4bytes
What? That's not the case at all, unless you specify it somewhere.
Maybe you are using a different SDK, but the ws2bth.h from PSDK 2003 R2 sets the structure
packing in the entire header to 1, which is why I included that line in my response.
sizeof(SOCKADDR_BTH) returns 30 on my system.
I am Curious why it's 32 on your build. What header files do you use and from where?
Of course, this still doesn't explain why substituting 30 doesn't work.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm using the CeGCC compiler for Linux to create PPC executables, along with it I'm using an older sdk, probably from eVC 4. Right now I have no idea why this isn't working.I've looked through many examples and I'm doing everything correct socket initialization etc and I'm still running up on this problem. The code compiles but this crashes on runtime.
-Steven Hicks CPACodeProjectAddict
|
|
|
|
|
(Steven Hicks)n+1 wrote: Right now I have no idea why this isn't working.
Me neither, sorry! The original code looked like good Winsock calls to me
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You are calculating that correctly (2 8 16 4)....could this be a platform issue with allignment? Size of SOCKADDR_BTH is returning 32.
Could you test sizeof(SOCKADDR_BTH) on your machine?
-Steven Hicks CPACodeProjectAddict
|
|
|
|
|
(Steven Hicks)n+1 wrote: could this be a platform issue with allignment? Size of SOCKADDR_BTH is returning 32.
Could you test sizeof(SOCKADDR_BTH) on your machine?
That's what I was wondering originally. Using Platform SDK for Windows Server 2003 R2 header
files, sizeof(SOCKADDR_BTH) returns 30.
I was thinking it may be different building for CE but I can't find anything that indicates that
it should be.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've used SetWindowsHookEx() and placed the hook procedure in a DLL, as it is a global hook.. I was just wondering how I call the CallNextHookEx() API from the hook procedure in the DLL because the first parameter is the hook handle, which I don't have access to, as SetWindowsHookEx() is called from the actual executable. Is there a way of obtaining this hook handle, or sharing the handle with the DLL from the executable code?
I'm working in C/C++ so no MFC
Thanks for your help!
--PerspX
|
|
|
|