|
GetMessage is a #define for GetMessageA or GetMessageW depending on wheather you are using unicode or not...
you should declare a method name that is already defined by windows, instead chose some other name.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
thanks for all your answers. what i still don't understand is how is one supose to know what excaly are the functions "already defined by windows" in order to avoid reusing their names...
|
|
|
|
|
class _DSpreadSheet : public COleDispatchDriver
HWND glhTargetWnd;
glhTargetWnd is a ole's handle.
the ole is _DSpreadSheet.
if to get CButton point, that is simple.
CButton *p;
p = (CButton *)CWnd::FromHandle(glhTargetWnd);
I can try :
CWnd cwMe;
_DSpreadSheet Test;
LPUNKNOWN obj = NULL;
if(cwMe.Attach(glhTargetWnd)) //this is ok
{
obj = cwMe.GetControlUnknown(); //the obj is NULL !!!!!
//cwMe.GetControlUnknown() maybe error?
}
else
{
//error code
}
if(obj == NULL)
{
//error code
}
else
{
Test.AttachDispatch((struct IDispatch *)obj);//because obj is NULL, this code can not run
}
please help me!!!
How can I do?
|
|
|
|
|
I have traces of a protocol (say a point-2-point data/control protocol) stored in files. I am thinking of writing a protocol validator, checking for the syntactic correctness as well as the semantic correctness (the correct flow as specified in the Spec).
The checking rules are put in a separate file & the inference engine loads these rules and checks for the validity of the data (from the trace files).
[rules file] + [trace file] ---(Inference engine)----> result
This also has to be lean & fast. I am now doing a proto based on some ideas I have on how this can be done...
but, I'd appreciate any ideas from you people on how this can be efficiently done (or how this is actually done ).
Thx
|
|
|
|
|
how do you recursively search for a folder with a certain name? If anyone has source code please post it
I am pretty sure to use Cfilefind but then again this is why i am asking.
-Ryan M.
|
|
|
|
|
<br />
BOOL SearchFolder(CString folder)<br />
{<br />
CFileFind finder;<br />
CString strWildcard(folder);<br />
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);<br />
CString str;<br />
while (bWorking){<br />
bWorking = finder.FindNextFile();<br />
if (finder.IsDots())<br />
continue;<br />
else if (finder.IsDirectory()){<br />
str = finder.GetFilePath();<br />
SearchFolder(str);<br />
}<br />
else{<br />
str=finder.GetFilePath();<br />
DoingFile(str);<br />
}<br />
}<br />
finder.Close();<br />
return TRUE;<br />
}<br />
Good luck.
|
|
|
|
|
Normally, I recommend using MFC classes whenever possible except for CFileFind, which I find to be abhorent. I'd also normally give you some hints and have you learn for yourself, but I don't feel like it, so here is a non-MFC program for you:
#define WIN32_LEAN_AND_MEAN
#include < windows.h>
#include < shlwapi.h>
#include < stdio.h>
#include < tchar.h>
#pragma comment(lib, "shlwapi.lib")
inline
bool IsDots(LPCTSTR pFileName)
{
int i = 0;
while (pFileName[i])
{
if (pFileName[i++] != '.')
return false;
}
return true;
}
bool Walk(LPCTSTR pDirToFind, LPTSTR pFinalPath)
{
bool foundDir = false;
WIN32_FIND_DATA findData;
HANDLE hFind = ::FindFirstFile(_T("*"), &findData);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (::CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, findData.cFileName, -1, pDirToFind, -1) == CSTR_EQUAL)
{
::GetCurrentDirectory(MAX_PATH, pFinalPath);
PathAddBackslash(pFinalPath);
_tcscat(pFinalPath, findData.cFileName);
foundDir = true;
}
else if (!IsDots(findData.cFileName))
{
::SetCurrentDirectory(findData.cFileName);
foundDir = Walk(pDirToFind, pFinalPath);
::SetCurrentDirectory(_T(".."));
}
}
} while (!foundDir && ::FindNextFile(hFind, &findData));
::FindClose(hFind);
}
return foundDir;
}
int _tmain(int argc, TCHAR* argv[])
{
if (argc != 2)
{
_putts(_T("FindDir <<dir>>"));
return 1;
}
TCHAR finalPath[MAX_PATH];
if (!Walk(argv[1], finalPath))
{
_tprintf(_T("Directory \"%s\" could not be found\n"), argv[1]);
return 1;
}
_tprintf(_T("Directory path is: %s\n"), finalPath);
return 0;
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I dont think its a nice idea to use SetCurrentDirectory().Which can reflect at a different place in your project.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
A) You should NEVER assume what the directory is in your project.
B) Just call GetCurrentDirectory() before the call then restore it afterward. You could encapsulate it in a class (which I have.)
C) Alternatively, you could use the final directory buffer to build up the path as you go. It requires a little more parsing, but if you preserve the length to make it easier to strip the path back down, it's not difficult. (Yes, I've done it this way, especially in the DOS days.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Please advise me how to create a *.ini file in MFC & how to operate on this file.
I would like to make a data link in MFC, please show me how ?
|
|
|
|
|
Look up WritePrivateProfileString() and ReadPrivateProfileString()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
|
I want to calculate the golden ratio (Phi) and (phi)... I know how to do the equation, pretty simple, but I want to make the program so it will output a load of numbers instead of like... .61803 but I want a longer number... how can I do this??
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Are you looking for a numeric C++ class that holds more than 64bit integer?
Kuphryn
|
|
|
|
|
maybe using long float my_variable;
|
|
|
|
|
I mean, can I somehow make a type MORE precise to calculate phi or Phi to the nth digit?? like somewhere about 100 or no?
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
i made a dll in which
i added a microsoft web browser control in a dialogue
but it doesnt shows the dialogue box. but if i remove the web browser control
then it works well.
please suggest someway
|
|
|
|
|
I recommend using shdocvw.dll. Is what Internet Explorer uses to navigate. Is on windows/system32
|
|
|
|
|
I have made a window in Win32. I would like to somehow handle the minimize event, so I can do stuff when the user clicks the minimize button. Does anyone have any clue how to do this? Any help is appreciated.
-Dev578
|
|
|
|
|
Both of the links I posted to your previous question 'Running a program in the taskbar' show how to handle the minimize event (or, one way of doing it)
Did you look at these examples ??
There are plenty of other examples, you can search here, or google
In general terms, when designing (say a dialog app), you must set 'Minimise Box' under Dialogue Properties -> Styles.
You then write/modify the handler for the 'OnSysCommand' - an example of such is shown below :-
void CMBFGWMS1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
// Decide if minimize state changed
bool bOldMin = bMinimized_;
if (nID == SC_MINIMIZE) {
bMinimized_ = true;
}
else if (nID == SC_RESTORE) {
bMinimized_ = false;
}
CDialog::OnSysCommand(nID, lParam);
if (bOldMin != bMinimized_) {
// Minimize state changed. Create the systray icon and do
// custom taskbar button handling.
SetupTrayIcon();
SetupTaskBarButton();
}
}
}
the line
nID == SC_MINIMIZE
is actually the bit that checks to see if the minimise button/request was activated (since there are a number of different requests that all come through OnSysCommand) - this is how the request is handed to your program ...
How about you try using one of the examples, and post some code back to CP if you want more help - its easier for us to work with 'posted code' than vapour ....
'G'
|
|
|
|
|
OnSize (with type == SIZE_MINIMIZED)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
And another way is to handle WM_NCLBUTTONDOWN or WM_NCLBUTTONUP messages and check wParam parameter for HTMINBUTTON value. You should read in MSDN for more information .
|
|
|
|
|
Hi,
I have a custom draw list box, I handle WM_DRAWITEM to draw the items but it seems that only the selected items are drawn. The others aren't being invalidated. Anyone know why?
cheers,
roel
|
|
|
|
|
Are you checking the item state and setting TextColor correctly? (DRAWITEMSTRUCT::itemState)
That's just a guess, without code it's hard to tell what's going wrong.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thanks for your reply, after letting it rest and getting some sleep it only took me 10 minutes to find it Problem was that I was using WTL's CDC and not CDCHandle, CDC destroys the DC when it goes out of scope... Argh stupid me, I've made this mistakes dozens of times for fonts and cursors and bitmaps, just when I thought that I wouldn't make it again this shows up... Anyway thanks for your answer.
|
|
|
|