|
I have a problem on extern function templates. The syntax compiles OK, but gets:
error LNK2001: unresolved external symbol "int __cdecl Next(int)" (?Next@@YAHH@Z)
Only function templates cause such problem; general functions like
int MyFunction(void* p)
does not cause such problem.
My VC++ is 6.0 sp5.
Here is the example code...
In the first file main.cpp:
/* *********************** */
////////////
// main.CPP
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248dusing namespace std;
template<class T> extern T Next(T val);
void main()
{
int a = Next(3);
cout << "a = " << a << endl;
}
/* *********************** */
In the second file function.cpp
///////////////////
// function.CPP
template<class Tᡊe9ac73-238b-46be-991d-0f050c37248dT Next(T val)
{
return val++;
}
/* ************ */
Maxwell Chen
|
|
|
|
|
As main.cpp does not see the definition of Next , which is hidden in function.cpp , it is required that function.cpp "exports" the instantiation of this template for int s like this:
template<class T>
T Next(T val)
{
return val++;
}
template int Next(int); This is not a very smart design, as function.cpp has to know in advance for which types Next is going to be used. Usually, it is better to have the definition of all templates inside header files included by the "consumer" .cpp s.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
Sorry guys, but how can i pass a parameter to
the dll which i've hooked to the system
Please help
Sameer
|
|
|
|
|
Export some function to accept the parameters and have them stored in a data shared segment (if you need help about shared segments, check Phil McGahan's article How to share a data segment in a DLL.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
i did this.. and made a function setfilename(char *)
which changes the filename..
but in my DLL mail i am doing fopen.. but now the
file is not being created
#pragma data_seg (".HookSection")
// Shared instance for all processes.
static HHOOK hHook = NULL;
// Change 2
static char szFilename[_MAX_PATH] = "";
// Change 2
#pragma data_seg ()
|
|
|
|
|
setfilename does a strcpy to szFilename , right? If so, everything should work fine. Check the following:- Make sure the filename is correctly set by displaying it somehow (say with a
MessageBox ) right before calling fopen .
- Maybe the file is being opened in a directry different to what you expected.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually i had put that code in DLLMain, but now it
is inside HookProc..
Now the problem is that when i run some application,
lot of entries of the same application are logged on
to my log file.. whereas first it was just one
Sameer
|
|
|
|
|
Hi.
I would like to implement a progress bar one pane of the statusbar. Current, the statusbar has two panes. Pane 1 (index 0) is the default separator where you see "Ready." The second pane is contains the progressbar. Here is the code.
-----
CRect progressRect;
m_wndStatusBar.GetItemRect(1, &progressRect);
m_ProgressBar.Create(WS_CHILD | WS_VISIBLE | SBPS_NOBORDERS | PBS_SMOOTH, progressRect, this, -1);
m_ProgressBar.SetRange(0, 100);
m_ProgressBar.SetPos(0);
-----
Here is the code that tests the progressbar.
-----
for (int i = 0; i < 100; ++i)
{
{
m_ProgressBar.SetPos(i);
::Sleep(25);
}
}
-----
For some reason, I do not see any sign of the progressbar working. I have an option in the menu to start the for loop. However, I do not see any sign of the progressbar, period. I am using SDI. The code above are all part of main.
Thanks,
Kuphryn
|
|
|
|
|
If your doing this loop in your user interface thread, then its not allowing the messages generated from your loop to be processed. Try adding this into the loop:
MSG msg ;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
{
::TranslateMessage(&msg) ;
::DispatchMessage(&msg) ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thanks.
Why is it not allowing me to update the progress bar in the UI thread?
Kuphryn
|
|
|
|
|
The UI thread pumps the windows messages that allows you controls to draw themselves. In your original function, you entered a lopp that updtaes the position in the control and then pauses the thread until you want to update it again. As the UI thread is not pumping the message queue in the loop, your controls never update, if effect the UI of your app is stalled until the function completes. You should then find all the messages get processed, and the progress will be shown at 100% complete.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thanks.
I do not see the progressbar anywhere on the statusbar (in main) at all.
A member at Codeguru posted a segment of code he used for a something I am trying to implement. He used CDialogBar and CProgressCtrl.
Here is the link to that thread:
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vc&Number=367944&page=2&view=collapsed&sb=5
He used some really innovative MFC tools such as the CDialogBar and ShowControlBar() function. I have Jeff Prosise's MFC reference, but I do not remember Prosise mentioning those about those tools.
I had problems getting the code from the link above to run. I got the error "bardlg.cpp" debug error. Maybe you can test it out too.
Kuphryn
|
|
|
|
|
Oh, I understand now. I receive a response at Gamedev about the UI thread (main frame) not able to update the progress bar. I am not familiar with the reason behind that.
I would like to have the progress bar in a pane of a statusbar. That means I will have to declare the progress bar in main (UI thread) and update it from there. If the UI thread cannot update the progress bar, then is it possible to even have a progress bar in main (UI thread) at all?
Kuphryn
|
|
|
|
|
Okay. I finally implemented that progress bar in my program. It works great.
I have a question. A member at Anandtech posted a link to a source code from CodeProject. The author of the progress bar uses the function PeepAndPump(). He uses it to process other messages while the progress bar updates. I do not see that function in MSDN. Is there a similar function in MFC?
Kuphryn
|
|
|
|
|
Hi,
I am using the COM interface given below for getting
the history of Internet Explorer..
IEnumSTATURL* pIEnumSTATURL = NULL; // Enumerated URLs
UrlHistoryStg2* pUrlHistoryStg2 = NULL;
After getting the history i clear the history using
ClearHistory()\
And i am facing a problem, Sometimes some URLs are not deleted from the history and are there in it...
What may be the cause of this behaviour..
And how to delete them.
Regards
Sameer
|
|
|
|
|
Hi.
I can considering to add a new feature to a program I am current working on. I will explain briefly on the program.
I am working on a program that is basically a text editor. it looks and feels almost like Notepad.
I want to add a feature similar that includes a split view. The program will operate using two views. The views are split in horizontally. The top view is the original text. So if the user opens a text file that has "Hello MFC," then the program will always display the original text on the top view. The second view located at the bottom is the modified view. I have a feature in the program where, for example, it will seach a text file and capitalize the first letter of a sentence. Once done, I want to display the modified text in the second view.
I would like to know the best approach for something like that with these key feature:
1) separate and unique saves
--- the user can save *both* files separately. the save features on the menu applies to the original text (top view).
What is the best approach to somehow mark what view the user wants to save? I have two ideas.
1) upon save, the program would save whatever view is *active* (cursor).
2) have a second toolbar for the view #2
I am not sure how to implement either of the above. I tried adding a second toolbar, but the program ignores it (I did not see it).
Thanks,
Kuphryn
|
|
|
|
|
You could use the GetDocument of the CView then use the IsModified of the CDocument , to check if the data in document is dirty , note you could use explicitily the SetModifiedFlag of the CDOcument associated with the current View then override the SaveModified function of the CDocument to do the proper action, since the default use a normal prompt to present the user the option of saving the changes.
Cheers,
Joao Vaz
The Most Unhappy and Frustrated TCL programmer,besides that a Happy guy
|
|
|
|
|
|
I am creating a MDI application and I want an icon at the taskbar for every child like Excel has an icon for every workbook. I tried to create a dialog for every child and minimize it, I can activate the corresponding doc, but the icon is not being checked, I also can not minimize the window and at slower systems, you see the dialog appear and "fly away" to the taskbar.
I hope somebody knows a solution.
Regards,
Danny Springer
|
|
|
|
|
If you have VC 7 there is an option for a Doc/View like that. I can't remember the name off hand.
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179
†
|
|
|
|
|
Nope, VC6, but I will remember this.
Regards,
Danny Springer
|
|
|
|
|
I am not sure whether this is a nice idea, but make each of those mdi children a direct child of the desktop.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Why you think, that it's MDI? It's another architecture, and required another programming. See sources of MFC 7.0 for details.
|
|
|
|
|
Use the WS_EX_APPWINDOW style for every window that you want to appear in the taskbar.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi.
Microsoft offers an impressive feature in MFC that routes WM_COMMAND and COMMAND_UPDATE messages via command routering using OnCmdMsg(...) in main and a function in doc to traverse through all active view. The drawback, however, is that it only works for COMMAND messages, not any messages.
I wonder if there is a technique similar to the one mentioned above for specific command type such as user commanders (WM_USER_MYCOMMAND, etc). The message map would look like this:
// ON_MESSAGE(WM_USER_MYCOMMAND, OnMyCommand)
Thanks,
Kuphryn
|
|
|
|