|
I use a .h for version info and then use the #defs in the Version Resource as follows:
FILEVERSION 1,_SUL_VER_MINOR,_SUL_BUILD,_SUL_RBLD
PRODUCTVERSION 1,_SUL_VER_MINOR,0,0
VALUE "FileVersion", "1." _SUL_VER_MINORS "." _SUL_USER_BUILD "." _SUL_USER_RBLD "\0"
VALUE "ProductVersion", "1." _SUL_VER_MINORS " " _SUL_BUILD_DATE "\0"
and the .h for this:
#define _SUL_BUILD_DATE "16/12/2004" // rem: "dd/mm/yyy" If this format changes so must: <A HREF=".\ED_Install.cpp#App Release Date">
#define _SUL_VER_MINOR 30
#define _SUL_VER_MINORS "30"
#define _SUL_BUILD 0
#define _SUL_USER_BUILD "0"
#define _SUL_RBLD 0 //### See note above re: 2 digits except when leading 0. so 2.10 is right, 2.01 isn't. ###
#define _SUL_USER_RBLD "0"
The only hassle with this is that the VC6 Resource Editor occassionally looses the plot and the #defs in the VERSIONINFO get replaced by there literal values. I check this before each release and copy and paste the correct lines back in.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Neville Franks wrote:
The only hassle with this is that the VC6 Resource Editor occassionally looses the plot and the #defs in the VERSIONINFO get replaced by there literal values. I check this before each release and copy and paste the correct lines back in.
To correct this problem, create an external .RC file and include it in the main resource file, for example:
<br />
#include "Version.h"<br />
...
<br />
2 TEXTINCLUDE DISCARDABLE <br />
BEGIN<br />
"#include ""Version.h""\r\n"<br />
"\0"<br />
END<br />
...
<br />
3 TEXTINCLUDE DISCARDABLE <br />
BEGIN<br />
"#include ""version.rc"" // version resource\r\n"<br />
"\0"<br />
END<br />
...
<br />
#include "version.rc"
Your "version.rc" may contain a template version resouce and string table which can be shared across projects and it won't get corrupted when working with the main resource script. TEXTINCLUDE 2 and 3 give a way for including files in your resource and protecting the references from the rewriting that the resouce editor does.
|
|
|
|
|
The # operator only works within a #define , so you need to do something like:
#define MAJOR_VERSION 1
#define MINOR_VERSION 01
#define MAKESTRING(x) #x
STRINGTABLE DISCARDABLE
BEGIN
IDS_SPLASH_HEADING "MyApp Version " MAKESTRING(MAJOR_VERSION) "." MAKESTRING(MINOR_VERSION)
END
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
-----
Magnae clunes mihi placent, nec possum de hac re mentiri.
|
|
|
|
|
Hello,
I have two questions, one is more general and it's about diamond shpae inheritance, C,B inherit A virtually ans D inherits C and B.
a lot of people tell me to avoid diamond inheritance, but they don't know to explain the reasons. so that's the first question, does any one know problems that pop up when using that inheritance?
the socond question is about efficiency,
suppose I have class A, the class has a member variable "v" that can be only 2 values, the value doesn't change after A is allocated. now A has a function that returns '1' if "v"==something and '2' otherwise.
the question is what will be more efficient? to write the function using 'if' statement, or having two classes with virtual function.
to answer that assume that the function is called A LOT of times, but also there are A LOT of allocations of A (or the inherited classes).
thanks,
Guy.
|
|
|
|
|
1. well for C, B there won't be much trouble, it's actually D you have to take care of. Suppose that B and C both have a function called Print()? There 's probably a way to tell the compiler which one to use, but this isn't really O-O programming in my opinion, if your project gets more complicated in time you'll notice that you'll get more and more in trouble.
O-O => no multiple inheritance (as good practice)
If I understand what you mean I would go for the if-statement. It's simpler.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
for the second question about efficiency try to write the funcion with inline assembler like this:
/////// header file ////////////
class A//suppose I have class A, the class has a member variable "v"
{
unsigned long v;//or long
long __fastcall func(void);//now A has a function that returns '1' if "v"==something and '2' otherwise.
long something;//it can be a local var of same type as v
};
/////////////// this is the cpp file //////////////////
__declspec(naked)long A::func(void)
{
__asm
{
push ebx //save ebx
mov ebx,1
mov eax,v
cmp eax,something //compare
mov eax,0
cmovne eax,ebx //if no equal, make eax=1 else eax=0
inc eax //increase eax
pop ebx
ret //eax is the return value
}
}
the return value of func will be 1 if equals or 2 if not.
regards.
Vagelis
|
|
|
|
|
me think the compiler will do something similar if you use simple code.
and in your example, you need to use another variable, which is not necessary.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hmm, thanks, but isn't it 'if' statement implemented in asm?
I wanted to know if the virtual functions table initialization tradeof is high or not.
thanks anyway,
Guy.
|
|
|
|
|
diamond inheritance is a problem when you have virtual methods; the derived class doesn't know which base class method to call.
about efficency, don't create a new class for nothing, a simple inline method will be enough, let the compiler do the job.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi!
i have got a Pointer to a window and want to get its toolbar.can anybody help me how to get toolbar from Window object.
|
|
|
|
|
One way is to use EnumChildWindows() and in the EnumChildProc() check the Window Style or Class to see if it is the Toolbar.
Another way is to use FindWindowEx() and specify the Toolbar class name.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Hi All,
I’m currently having trouble with inconsistent behavior some Win32 API BegingUpdateResource, UpdateResource and EndUpdateResource usage; which are used to manipulate resources in Win32 Binaries, below is a fuller description of the problem, could someone please help.
Development environment:
VC++, with Visual Studio .Net 2002, on Win2k (Service Pack 4)
Test environments:
WinXP, Win2K, WinNT
Problem description:
The assignment is in the translation domain, which requires updating resources in the Win32 binaries with translated text (in a language different from the original binary). In-order to achieve this we use the following Win32API: (FindResourceEx, LoadResource, LockResource …e.t.c to achieve this.)
Additionally this requires us to change the language ID of the resources contained, as there is no apparent method that would directly allow this, we chose the following approach:
We delete necessary resources using the API: (BeginUpdateResource, UpdateResource with NULL buffer and 0 size and EndUpdateResource)
And then update the
Following is a description of the issues/problems that I’ve encountered:
On deleting a single resource from a Win32Binary, I’ve observed that “sometimes” all resources are deleted (which reduces a source exe of 9MB, to 98KB destination exe).
This is typically the case for very large binary files, however, this is not very predictable, it seems to work fine on some boxes and not so well on some others, we are yet to conclude on the commonalities among the problem causing environments.
Below is a snippet of the code that I use to do this, could someone please help in pr
Code Snippet:
//Deleting resource(English):-
HANDLE hUpdateRes =
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
BOOL flgResultInt1 = FALSE;
long lBlockId = 100;
flgResultInt1 = UpdateResource(hUpdateRes, 0x05, MAKEINTRESOURCE(lBlockId), 1033, NULL, 0 );
BOOL flgRes = FALSE;
flgRes = EndUpdateResource(hUpdateRes, FALSE);
//Updating resource(Japanese):-
HANDLE hUpdateRes =
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
BOOL flgResultInt1 = FALSE;
long lBlockId = 100;
flgResultInt1 = UpdateResource(hUpdateRes, 0x05, MAKEINTRESOURCE(lBlockId), 1041, (LPVOID)buff, sizeof(buff) );
BOOL flgRes = FALSE;
flgRes = EndUpdateResource(hUpdateRes, FALSE);
Maharaj.M
|
|
|
|
|
MaharajM wrote:
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
...
BeginUpdateResource((LPCWSTR)m_strDestFilePath.GetBuffer(), FALSE);
Unless you are modifying the contents of m_strDestFilePath , the calls to GetBuffer() are unnecessary, and could potentially cause problems.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i would like to know how to send midi data to the usb using windows midi driver???i have already sent this midi data to the midi sw synth(default of window midi player),how can i route it to the usb driver???i am not supposed to make my own driver but use the already existing windows drivers!!!!!.....
please help.....
|
|
|
|
|
Hello..
How do i import a third party libary (.lib) in Visual C++ .NET. I keep on getting the LNK2019 error during linking. I already added an entry on
Project->Properties->Linker->Advanced->Import Library = $Path\MyLib.lib..
I know this is pretty much the way to add libraries in VC++ 6...
But I still get the same error....
|
|
|
|
|
Ok.. sorry for this post.. I got this to work already.. I was supposed to insert the .lib file on the ... LInker->Input parameter...
sorry for the dumb question...
|
|
|
|
|
How to make a program that is similar to Sysmantic AntiVirus ,namely a windows service with a tray icon can pop a main window.if you know ,please tell me more.thanks a lot !
|
|
|
|
|
|
Hi,Everyone:
i create a project CFormView as its base class. i add "List Control" in the Mainform, and i use the "List Control" with code below:
-----------------------------------------------------------------------
class CvcydcjView : public CFormView
void CvcydcjView::OnInitialUpdate()
{
...
CListCtrl* pList = (CListCtrl*) GetDlgItem( IDC_LIST_MEM);
pList->InsertColumn(0, "TestColumn", LVCFMT_CENTER,40);
...
}
-----------------------------------------------------------------------
now i want to use the control in my other class, obviously i can't use that code to get the DlgItem, can anyone help me to solve the problem? -- use the Mainform Control in other class.
Thank you so much!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
First Obtain the ptr of view class "CvcydcjView"
as
CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd();<br />
ASSERT(pMainFrmWnd != NULL);<br />
CvcydcjView* pYourView = NULL;<br />
CWnd* pchildWnd = pMainFrmWnd->GetWindow(GW_CHILD);<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
while(childWnd->GetSafeHwnd() != NULL)<br />
{<br />
ASSERT(childWnd->GetSafeHwnd() != NULL);<br />
if(childWnd->GetRuntimeClass()->m_lpszClassName == "CvcydcjView")<br />
{<br />
pYourView = (CvcydcjView*)childWnd;<br />
break;<br />
}<br />
childWnd = childWnd->GetWindow(GW_HWNDNEXT);<br />
}<br />
ASSERT(pYourView != NULL);
Now you have got ptr to your class you can call the functions as
CListCtrl* pList = (CListCtrl*)pYourView->GetDlgItem( IDC_LIST_MEM);<br />
pList->InsertColumn(0, "TestColumn", LVCFMT_CENTER,40);
At the moment i dont remember whether GetDlgItem() is public or not.
If its not public create your own function that should be public which calls GetDlgItem inside the class as
The below is the public function
CWnd* CvcydcjView::getItem(UINT p_nResourceID)<br />
{<br />
return GetDlgItem(p_nResourceID);<br />
}
now call this function form your other class as
CListCtrl* pList = (CListCtrl*)pYourView->getItem( IDC_LIST_MEM);<br />
pList->InsertColumn(0, "TestColumn", LVCFMT_CENTER,40);
..RR..
|
|
|
|
|
Hi,Dear Rahim:
first of all, thank you so much for your reply!
as you said:
Rahim Rattani wrote:
CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd();
but i get these errors:
-------------------------------------
error C2065: 'CMainFrame' : undeclared identifier
....
and in my project i don't have CMainFrame Class cos it's Form based
Do you have any other suggestions?
Thx a million! (it's really lots of informations you provide!)
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
If you are workin on a dialog based application, the dialog is declared and created in InitInstance() of the Application class.
Why dont u declare the dlg as public in the class, instead of InitInstance().
Create and display it in InitInstance but declare it as a public variable.
Then you will be able to accessit anywhere as theApp.yourDlgVariable;
..RR..
|
|
|
|
|
Rahim Rattani wrote:
dialog based application
it's a bit different.
i created the project using single document and last step choose form-base, so i do have CvcydcjApp class as well as CvcydcjDoc & CvcydcjView.
i don't know whether your method can be used in this case and how ? could you tell me the details.
Thx a million!
Best wishes!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
If you are using a SDI application, then you ould definitely have a CMainframe class (the one i mentioned in my first reply).
CMainfrmae is the class derived from CFrameWnd, and without it u can cannot create a SDI application.
Check it you will have a CMainFrame class in your application and let me know.
The solution in my first reply should definitely work.
Let me know if you have a class name CMainframe (or a class derived from CFrameWnd)
..RR..
|
|
|
|
|
i'm so sorry! i do have CMainframe Class!
i'm so stupid! sorry!
i'll try your first method!
Thx a million!!!!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|