|
I did get the missing functions error as you stated. In every example I found involving Inpout32.dll it seems that stdafx.h needs to be loaded. I think that is where the cpp related issues began. I did go through the project settings and set the stdafx.h to create the .pch file and have the c file I am working on to use the .pch file like how the example projects do. The error I have been running into is "fatal error C1853: 'Debug/gblast2.pch' is not a precompiled header file created with this compiler"
Chris
|
|
|
|
|
Hello.
Try a "Rebuild All", first of all. If it doesn't work, turn off the use of precimpiled headers.
You can do it either for the entire project or for a specific source file.
If you want to turn it off for a specific file, do this (VC 6):
In "File View", highligt a file. Right-click, select "Settings...".
In The C/C++-tab, select Category Precompiled Headers. Select "Not using precompiled headers". Click OK.
For the entire project, Select "Project->Settings. Do the same operation as before.
This should help. If it works in Debug build, don't forget to do the same for Release build! (A common mistake of mine.)
Good luck.
Kakan
|
|
|
|
|
Thanks again for your help. I did find some information and successfully ran inpout32.dll by means of GetProcAddress (even though I wanted to call the functions like I could in C++) The address of the example is at: http://www.unixwiz.net/techtips/win32-callconv.html
|
|
|
|
|
How do you copy memory using this function?
Suppose you have
PBYTE source1 = new BYTE[2];
PBYTE source2 = new BYTE[2];
PBYTE source3 = new BYTE[2];
PBYTE source4 = new BYTE[2];
PBYTE source5 = new BYTE[2];
PBYTE source6 = new BYTE[2];
PBYTE source7 = new BYTE[2];
PBYTE source8 = new BYTE[2];
PBYTE destination = new BYTE[16];
how can you copy all of the sources into "destination" ?
memcpy(destination,source1,2); // this would copy the source1 into destination
memcpy(destination,source2,2): // this would not start from where the first one ended !! rather it would over write !
Or is there a better method?
-Cindy
|
|
|
|
|
|
Thats what I thought too,
but that DOES NOT seem to work,
to be more exact
memcpy((char*)destination,(char*)source1,2)
memcpy((char*)destination+2,(char*)source2,2)
memcpy((char*)destination+4,(char*)source3,2)..and so on
is what I had tried, and destination only has source1, I dont think the rest are being copied, why ? how ?
-Cindy
-- modified at 22:02 Tuesday 22nd November, 2005
|
|
|
|
|
What is PBYTE ?
memcpy((char*)destination+2,(char*)source2,2)
is it an order of operations problem ? What if you did
memcpy(((char*)destination)+2,(char*)source2,2) ??
Why do you need the cast at all, if the length of PBYTE[2] is 2 ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
PBYTE is an unsigned char *, right ? Stupid macros.
Anyhow, this works fine for me:
char c1[2] = {'a', 'b'};
char c2[2] = {'c', 'd'};
char c3[2] = {'e', 'f'};
char c4[2] = {'g', 'h'};
char * c = new char[8];
memcpy(c, c1, 2);
memcpy(c + 2, c2, 2);
memcpy(c + 4, c3, 2);
memcpy(c + 6, c4, 2);
memcpy(&c[6], c1, 2);
memcpy(&c[4], c2, 2);
memcpy(&c[2], c3, 2);
memcpy(&c[0], c4, 2);
Note I did it two different ways, both worked.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
HELLO.
i am trying to open two different windows using two buttons in the attached menu of the main window. first window should have similar style (color and size) like the main window, the second window should have different style.
here is what i got until now:
<br />
#include <windows.h><br />
#include "resource.h" <br />
<br />
HWND hwnd = NULL;<br />
HBRUSH g_hbrBackground = NULL;<br />
const char lpClassName[] = "myWindowClass";<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(msg)<br />
{<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDM_NewWin1:<br />
break;<br />
<br />
case IDM_NewWin2:<br />
break;<br />
<br />
case IDM_EXIT:<br />
DestroyWindow(hwnd);<br />
break;<br />
}<br />
break; <br />
<br />
case WM_CLOSE:<br />
DestroyWindow(hwnd);<br />
break;<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
break;<br />
default:<br />
return DefWindowProc(hwnd, msg, wParam, lParam);<br />
}<br />
return 0;<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
WNDCLASSEX wc;<br />
MSG Msg;<br />
<br />
wc.cbSize = sizeof(WNDCLASSEX);<br />
wc.style = 0;<br />
wc.lpfnWndProc = WndProc;<br />
wc.cbClsExtra = 0;<br />
wc.cbWndExtra = 0;<br />
wc.hInstance = hInstance;<br />
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+18);<br />
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);;<br />
wc.lpszClassName = lpClassName;<br />
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);<br />
<br />
RegisterClassEx(&wc);<br />
<br />
hwnd = CreateWindowEx(<br />
WS_EX_CLIENTEDGE,<br />
lpClassName,<br />
"My Window",<br />
WS_OVERLAPPEDWINDOW,<br />
0, 0, 480, 240,<br />
NULL, NULL, hInstance, NULL);<br />
<br />
ShowWindow(hwnd, SW_SHOW);<br />
<br />
while(GetMessage(&Msg, NULL, 0, 0) > 0)<br />
{<br />
TranslateMessage(&Msg);<br />
DispatchMessage(&Msg);<br />
}<br />
<br />
return Msg.wParam;<br />
}<br />
THANKS FOR HELP.
STEFAN.
|
|
|
|
|
Using GDI+ to load a PNG 32 bit image with transparency.
I draw the image on a static control and I get this result :
Image
with this code in the WM_PAINT :
case WM_PAINT:
{
if ( this->m_pImage != NULL ) {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint( this->m_Hwnd, &ps );
RECT rect;
GetClientRect( this->m_Hwnd, &rect );
Graphics grphx( hdc );
grphx.DrawImage( this->m_pImage, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
EndPaint( this->m_Hwnd, &ps );
bParsed = TRUE;
return 0L;
}
}
break;
I'd like to have the transparent part stay grey.
Thanks
David
|
|
|
|
|
Fill the client rect with grey before DrawImage or change your image.
|
|
|
|
|
MFC UPDATE_COMMAND_UI doesn't work for dialog menu.
how to enable and/or disable menu items of a dialog's menu?
includeh10
|
|
|
|
|
Hi,
Check this[^]
Bye
Cool Ju
Dream Ur Destiny
|
|
|
|
|
thx.
currently I use a timer, it looks much simpler than code in your link.
includeh10
|
|
|
|
|
I use a method where the parent of the dialog (e.g. a view) relays its WM_IDLEUPDATECMDUI to its dialogs, mimicking what CFrameWnd does.
The CDialog-derived child in turn handles WM_IDLEUPDATECMDUI and calls UpdateDialogControls, which looks for the UI-functions to be called.
The reference linked in the code snipped desrcibes the process for a status bar, but all commandUIs are equal - it does work for, say, buttons to enable and disable on staus change of another button.
The advantage of how this works is that you work with the MFC, not against it.
ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)<br />
...<br />
LRESULT CMethodPage::OnIdleUpdateCmdUI(WPARAM, LPARAM)<br />
{<br />
UpdateDialogControls(this, false);
return 0L;<br />
}<br />
ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)<br />
...<br />
LRESULT CTreeBrowserView::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam)<br />
{<br />
if (m_pEditor == NULL) /no editor open<br />
{<br />
return 0L;<br />
}<br />
else
{<br />
return m_pEditor->SendMessage(WM_IDLEUPDATECMDUI, wParam, lParam);<br />
}<br />
}
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
-- modified at 8:55 Wednesday 23rd November, 2005
|
|
|
|
|
Hello,
I have a basic SDI Windows application that was created with the MFC Application wizard. I want to set the minimum size of the application window so the user can't make it smaller that 640x480. What's the best (easiest) way to do this?
Thanks!
-Ian
|
|
|
|
|
Ian Bowler wrote: What's the best (easiest) way to do this?
With CWnd::OnGetMinMaxInfo() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks! I'll look into that.
-Ian
|
|
|
|
|
Hi,
I have an application that reads a data file and then diplays the information in myCdocument class. I have no need to save the document in serialized form. However, I accidentally clicked on the File | Save menu and discovered that my input data file (which contains very important data I don't want to change) gets erased to zero bytes effectively destroying my original data. How do I turn off the ability of the built in File | Save or otherwise preserve my data file? Do I need to write the data back out? I read the data in using the older FILE declaration because the CFile class was more problems than it was worth.
Buck
|
|
|
|
|
You need to modify the toolbar and File menu so that Save is no longer available.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
or just override the parent method with no code in it and don't call the base class's Save().
My articles
BlackDice
|
|
|
|
|
The only problem with this approach is that by leaving the Save option intact, it gives the user a false sense of functionality.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi Buck
I happened to be doing something similar last week. I wanted to retrieve files produced by another application and had no need to read or write in serialized form. This doesn't exactly answer the question you asked, but I thought it might be of interest.
I obtained a file pointer from the CArchive object and did an ordinary read (in my case retrieving the contents of a text file as a single string). I didn't get any sense of the CFile class being more trouble than it was worth, because it was already there by default.
I gave the document class variables to accept the string and its length:
char* m_ps;
ULONGLONG m_FileLength;
and I edited the Serialize function as follows:
void COstructDoc::Serialize(CArchive& ar)<br />
{<br />
if (ar.IsStoring())<br />
{<br />
}<br />
else<br />
{<br />
CFile* fp;<br />
<br />
fp = ar.GetFile();<br />
m_FileLength = fp->GetLength();<br />
<br />
m_ps = new char[(size_t)m_FileLength];
<br />
fp->Read(m_ps, (UINT)m_FileLength);<br />
}<br />
}
The File | Open button works normally, and File | Save does nothing because there are no writes specified, but, if you wanted to write data back out again, this would be the place to do it.
I'm not sure why File | Save destroyed your data. The Serialize function would have done nothing by default. Did you alter the if (ar.IsStoring()) layout?
Best Regards
Cliff Hatch
-- modified at 6:02 Friday 25th November, 2005
|
|
|
|
|
Dear All
I am using a webBrowser control as part of my project which i am developing. After loading a web page within a dialog box, I am interested in segmenting the current web page into coherent blocks (for example: images, tables, lists). I have tried detecting collections of html elements (images, paragraphs, divs...) by retrieving them from an instance of the html document.
Now, i am not sure if its the right method to segment a web page. Because i will end up specifying (hard coding) which elements to detect (anchors (a), divs, tablerows (tr), tabledata(td), unordered lists (ul)... and so forth)
detecting such elements and storing them in blocks will create redundancy. for example may contain anchors . detecting each seperately will result in blocks within blocks !!!
Does any body have a good idea for implementing the segmentation. I hope i have put it forward and not confused you guys.
Your views will be very much appreciated
llp00na
-- modified at 13:26 Tuesday 22nd November, 2005
|
|
|
|
|
I've got a serious problem with SHFileOperation which, in short, disallow me to use it for copying files (I haven't tried it on deleting\moving\something else). The code below is showing the way I am using it.
<br />
CString szTo(theApp.m_szMwDir), szFrom(theApp.m_szOoTDir);<br />
szTo += "\\Data Files\\\0\0";<br />
szFrom += "\\*.*\0";<br />
SHFILEOPSTRUCT fos;<br />
fos.hwnd = m_hWnd;<br />
fos.pFrom = szFrom;<br />
fos.pTo = szTo;<br />
fos.wFunc = FO_COPY;<br />
fos.fFlags = FOF_NOCONFIRMMKDIR;<br />
fos.hNameMappings = NULL;<br />
fos.lpszProgressTitle = NULL;<br />
SHFileOperation(&fos);
The problem is that when I run the application it comes out with "Error, file not found" error generated by SHFileOperation. theApp.m_szOoTDir is initialized correctly so it can't be a problem. Now let's get to the strange part. Let's assume that theApp.m_szOoTDir = "C:\TR_OoT_Test\Data Files" (it has this value in my test app so I'll use it for convenience). I want to copy all files in it and its subdirs to the destination directory (around 1000 in total) hence the wildcards. So, as I've already told, the application comes out with an error that the file cannot be found. But if I will create a char array and hardcode the path into application...it works. The path is the same:
CString szTo(theApp.m_szMwDir);<br />
szTo += "\\Data Files\\\0\0";<br />
char szFrom[] = "C:\\TR_OoT_Test\\Data Files\\*.*\0\0";<br />
SHFILEOPSTRUCT fos;<br />
fos.hwnd = m_hWnd;<br />
fos.pFrom = szFrom;<br />
fos.pTo = szTo;<br />
fos.wFunc = FO_COPY;<br />
fos.fFlags = FOF_NOCONFIRMMKDIR;<br />
fos.hNameMappings = NULL;<br />
fos.lpszProgressTitle = NULL;<br />
SHFileOperation(&fos);
If I will dynamically create char array by copying, concatenating, converting from CString or any other ways it stops working. So in short it works only with path written down when I am initializing an array or pointer to char string and ONLY to char string. I am absolutly clueless why it is so and how to overcome it. I was trying different workarounds for a few days and came up with nothing. In short - I am desperate. Any input is really appreciated.
Thank you for you time.
|
|
|
|
|