|
CDialog1 is the name of the dialog class. To call a method of that class, you must have a variable of that class available.
Software Zen: delete this;
|
|
|
|
|
Is the different dialog, a dialog of a different application?
If it isnt so, does this help?
CWnd::GetDlgItemText<br />
int GetDlgItemText( int nID, LPTSTR lpStr, int nMaxCount ) const;<br />
int GetDlgItemText( int nID, CString& rString ) const;
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
When Compiling I get these errors.
Something to do with the Linking process??
--------------------Configuration: List - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
List.cpp
ListDlg.cpp
Generating Code...
Linking...
LINK : warning LNK4224: /PDBTYPE is no longer supported; ignored
List.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
ListDlg.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
List.obj : error LNK2001: unresolved external symbol __RTC_InitBase
ListDlg.obj : error LNK2001: unresolved external symbol __RTC_InitBase
List.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "public: __thiscall CListApp::CListApp(void)" (??0CListApp@@QAE@XZ)
ListDlg.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "public: virtual void * __thiscall CAboutDlg::`scalar deleting destructor'(unsigned int)" (??_GCAboutDlg@@UAEPAXI@Z)
List.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "public: virtual int __thiscall CListApp::InitInstance(void)" (?InitInstance@CListApp@@UAEHXZ)
ListDlg.obj : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
Debug/List.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
List.exe - 9 error(s), 1 warning(s)
Any Help
Thanks
-Mark
|
|
|
|
|
You need to include the library files for those functions.
like so:
#pragma comment(lib, "something.lib") //use what ever library file you need
|
|
|
|
|
Could you explain in a little more detail please
|
|
|
|
|
Ok... so first off you need to find what Library file contains those functions. I recommend google. Search for the unresolved external symbols you are having trouble with. I have to ask, what exactly is this program trying to do. I assume this is an MFC project so go try to find the libraries that MFC includes.
If this was no help then you might need to ask a professional. Like Michael Dunn
|
|
|
|
|
|
What I am trying to do is extract a file from a resource then write it into the system directory of windows. It compiles but it doesn't run correctly. I defined 1001 in resource.h and I included it also. I need help with this code here:
#include <windows.h>
#include "resource.h"
void main(void) {
char szFile[MAX_PATH];
char sysdir[MAX_PATH];
DWORD Size;
DWORD Written;
HINSTANCE hMod = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hMod, MAKEINTRESOURCE(1001), RT_RCDATA);
Size = SizeofResource(hMod, hRes);
HGLOBAL hLoad = LoadResource(hMod, hRes);
LPVOID lpResLock = LockResource(hLoad);
GetSystemDirectory(sysdir, sizeof(sysdir));
strcat(sysdir, "\\abcdef.exe");
strcpy(szFile, sysdir);
HANDLE hMake = CreateFile(szFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, NULL | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM, NULL);
if (hMake != INVALID_HANDLE_VALUE) {
WriteFile(hMake, lpResLock, Size, &Written, NULL);
CloseHandle(hMake);
UnlockResource(hLoad);
FreeResource(hLoad);
}
}
If anybody has code similar to this that works please post it.
|
|
|
|
|
So where exactly are you facing problem in this code?
How are you going to know where the error occured as:
- Your code never calls GetLastError() to find out if a call to WIN32 Resource API succeeded or not.
- FindResource() , LockResource() and LoadResource() returns NULL in case of an error, you are not even performing any checks for that condition too.
- Are you sure the call to CreateFile() is succeeding, try using GetLastError() to know why it failed.
- You are not comparing the value of variable Written with the variable Size to know exactly if a call to WriteFile() succeeded or not.
Points regarding your code:
1. Please move UnlockResource() out of the if block.
2. It is not necessary for Win32-based applications to FreeResource . A resource is automatically freed when its module is unloaded.
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
Here is a function that i wrote a while back that does work
BOOL ExtractResource(const HINSTANCE hInstance, const WORD nID, LPCTSTR szFilename)
{
BOOL bSuccess = FALSE;
HRSRC hResource = NULL;
if((hResource = ::FindResource(hInstance, MAKEINTRESOURCE(nID), _T("BINARY"))) != NULL)
{
HGLOBAL hFileResource = NULL;
if((hFileResource = ::LoadResource(hInstance, hResource)) != NULL)
{
LPVOID lpFile = NULL;
if((lpFile = ::LockResource(hFileResource)) != NULL)
{
DWORD dwSize = ::SizeofResource(hInstance, hResource);
if(dwSize > 0)
{
HANDLE hFile = INVALID_HANDLE_VALUE;
if((hFile = ::CreateFile(szFilename, GENERIC_READ|GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
{
HANDLE hFilemap = NULL;
if((hFilemap = ::CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL)) != NULL)
{
LPVOID lpBaseAddress = NULL;
if((lpBaseAddress = MapViewOfFile(hFilemap, FILE_MAP_WRITE, 0, 0, 0)) != NULL)
{
::CopyMemory(lpBaseAddress, lpFile, dwSize);
bSuccess = TRUE;
::UnmapViewOfFile(lpBaseAddress);
}
::CloseHandle(hFilemap);
}
::CloseHandle(hFile);
}
}
}
}
}
}
return bSuccess;
}
Call it like:
ExtractResource(::AfxGetInstanceHandle (), 1001, "C:\\Whatever");
You then put your files into you RC file like this:
1001 BINARY MOVEABLE PURE "C:\\WhatEverFile"
|
|
|
|
|
Here is how I have done it in an MFC application:
In the .rc2 file, include the file you want to extract
ResourceName ResourceType "ResourceFilename"
To extract it:
ExtractFile("ResourceName", "ResourceType", pathname);
bool ExtractFile(const CString& resourceID, const CString& resourceType, const CString& filename)
{
bool bOK = true;
HANDLE hRes = ::LoadResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
if (hRes != INVALID_HANDLE_VALUE)
{
DWORD sizeOfResource = ::SizeofResource(hInstance, ::FindResource(hInstance, resourceID, resourceType));
char *lpRes = (char*)::LockResource(hRes);
CFile file;
if (file.Open(filename, CFile::modeCreate | CFile::modeWrite))
{
file.WriteHuge(lpRes, sizeOfResource);
file.Close();
}
else
{
bOK = false;
}
::UnlockResource(hRes);
::FreeResource(hRes);
}
return bOK;
}
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
See if this article is of any help.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I'm not too saavy in Visual C++ programming as most of my C/CPP has been in embedded platforms.
I'm working on a host application which is a VC++ window. Essentially, for this one particular window I want it to stay on top all the time. I have added some code that was given to me by someone who has done it in another application before, but it does not seem to be working in mine. Can anyone help?
Here is what I have:
<code>
CWnd appWnd;
CWnd *pAppWnd;
pAppWnd = & appWnd;
pAppWnd = AfxGetMainWnd();
if (NULL != pAppWnd)
{
HWND appHandle;
appHandle = pAppWnd->GetSafeHwnd();
if (NULL != appHandle)
{
targetObj.m_pAppWnd = pAppWnd;
}
}
targetObj.m_bWindowStayOnTop = TRUE;
</code>
targetObj is another class which is essentially being called by this (no "gui" elements in that class) and in that class, inside of a loop that he is in, I have this part:
<code>
if (TRUE == this->m_bWindowStayOnTop)
{
BOOL bReturn = FALSE;
if (NULL != this->m_pAppWnd)
{
bReturn = this->m_pAppWnd->SetForegroundWindow();
}
}
</code>
It seems that the return from SetForegroundWindow() is 0 which means it is failing. But I don't know why! Any ideas?
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
::SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
If that works, I am a superman, seeing as I've done nothing like this for years. It's damn close though. setwindowpos takes as it's first parameter a value that allows you to make a window move to the top or bottom, or make it topmost (i.e. top and stay there ). You pass whatever you like for the position and size, and use flags to make them irrelevant.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You are my superman!
It wasn't exactly right, but (hang on..moving window now in my way)....it was damn close!
Appreciated!
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
KingTermite wrote:
hang on..moving window now in my way)....
LOL - brilliant.
And you're welcome
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Does anyone know of a source for info on how to set up the VC6 environment to work with the free VC7.1 compiler that Microsoft has made available?
I could probably puzzle it out for myself, but step-by-step directions would be so much nicer.
Thx
|
|
|
|
|
I haven't tried this, but my first thought was go to Tools->Options->Directories->Executable files. The compiler/linker/etc are in %VCDIR%\vc98\bin , so change that line to wherever the VC 7 tools are.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
Thanks, Michael, that's a start.
|
|
|
|
|
|
Compiler works - after I made a bunch of changes to the code (all STL-related) - but now I can't link.
|
|
|
|
|
Is using the StreamIn function the only way to add text to a rich edit control programmatically? Thanks.
- Aaron
|
|
|
|
|
SetWindowText() comes to mind.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The problem with that is I'm pretty sure it would remove the text that was already in the control. I'm looking for a way to be able to append to any text that is already in the control.
- Aaron
|
|
|
|
|
monrobot13 wrote:
I'm looking for a way to be able to append to any text that is already in the control.
You'll want to use ReplaceSel() then.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|