|
I'm trying to display a bitmap in a Dialog and I've created a static control named IDC_PICTURE. I added this through the resource editor and placed it in my dialog and associated a picture. The picture shows up fine when i run my program. What i want to do is change the picture during the program to a different bitmap. I added the second bitmap to the resource list (right under the first one) and I'm trying to figure out how I can get control over which bitmap is displayed. Usually, I work with simple edit boxes and I do the following to gain control over them.
CWnd * pWnd = GetDlgItem(IDC_BYTE0);//where IDC_BYTE0 is an edit control
pWnd->ShowWindow(SW_SHOW); // i use this to control it, in this case to make it show instead of hidden.
I want to do this:
CStatic *pPic = GetDlgItem(IDC_PICTURE);//where IDC_PICTURE is the static control of type picture
so i can do this
pPic->SetBitmap(IDB_BITMAP2) //where IDB_BITMAP is the first one and IDB_BITMAP2 is the second picture
This code doesn't compile because GetDlgItem returns a CWnd type pointer.. but how do i get the pointer I need to use the CStatic functions?
Thanks
Jeff Rothenberg
Project Engineer
Vector CANtech, Inc.
|
|
|
|
|
<br />
CStatic* pWnd = static_cast< CStatic* >( GetDlgItem( IDC_BYTE0 ) );<br />
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Just cast it to CStatic :
CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE);
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Anyone knows any good way to do that? I have a (raw-formatted) XML file and I need to build ADO recordset from it. The last resort would be parse the XML file and build the recordset from scratch
Hope there is a way to use the XML file as data source.
Thank you.
|
|
|
|
|
Unfortunately no, there is no such thing, unless you use ADO.NET
There is quite a bunch of Xml readers here in the SOAP XML section, I guess it shouldn't be that hard to reuse one of them, especially if the Xml content is simple (no deep use of namespaces, etc.).
How low can you go ? (MS rant)
|
|
|
|
|
I know ADO has a way to write out a recordset as XML. One would think it could read in an XML dataset as long as it conformed to some schema structure.
If you want to load the recordset to insert this data into a database, then you could consider transforming (XSLT) the XML to generate a file, that will be in the correct format for sqlloader or BCP. Lesser XMLDoc parsing code inside your application then.
|
|
|
|
|
I am trying to restore a registry key by using the RegRestoreKey. I keep getting an ERROR_ACCESS_DENIED (return value 5) from the function.
I have ensured that I have the SE_RESTORE_PRIVILEGE.
Here is my code. Any help would be appreciated.
<br />
<br />
<br />
HRESULT ModifyPrivilege(<br />
IN LPCTSTR szPrivilege,<br />
IN BOOL fEnable)<br />
{<br />
HRESULT hr = S_OK;<br />
TOKEN_PRIVILEGES NewState;<br />
LUID luid;<br />
HANDLE hToken = NULL;<br />
<br />
if (!OpenProcessToken(GetCurrentProcess(),<br />
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,<br />
&hToken ))<br />
{<br />
printf("Failed OpenProcessToken\n");<br />
return -1;<br />
}<br />
<br />
if ( !LookupPrivilegeValue( NULL,<br />
szPrivilege,<br />
&luid ))<br />
{<br />
CloseHandle( hToken );<br />
printf("Failed LookupPrivilegeValue\n");<br />
return -1;<br />
}<br />
<br />
NewState.PrivilegeCount = 1;<br />
NewState.Privileges[0].Luid = luid;<br />
NewState.Privileges[0].Attributes = <br />
(fEnable ? SE_PRIVILEGE_ENABLED : 0);<br />
<br />
if (!AdjustTokenPrivileges(hToken,<br />
FALSE,<br />
&NewState,<br />
sizeof(NewState),<br />
NULL,<br />
NULL))<br />
{<br />
printf("Failed AdjustTokenPrivileges\n");<br />
hr = -1;<br />
}<br />
<br />
CloseHandle(hToken);<br />
<br />
return hr;<br />
}<br />
<br />
<br />
HRESULT hr;<br />
hr = ModifyPrivilege(SE_RESTORE_NAME, TRUE);<br />
<br />
CRegKey regkey;<br />
CString sRegFile = "MyFile.reg";
<br />
regkey.Open(HKEY_LOCAL_MACHINE,"SOFTWARE");<br />
lRet = RegRestoreKey(regkey.m_hKey,sRegFile,REG_NO_LAZY_FLUSH);<br />
.<br />
.<br />
.<br />
<br />
<br />
Any help would be greatly appreciated.
Thanks
ashish
|
|
|
|
|
Look over Microsoft's specification of RegRestoreKey(). Maybe you left something out.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/regrestorekey.asp
Kuphryn
|
|
|
|
|
Editted: for better understanding, I suggest one read the MSDN-Q237870 before continue
Hello all,
We've here automated build-scripts (Batch files and also 4NT batch-files) that creates user environment at a central (build)server. One of the scripts also executes NMAKE <makefile> in order to build the application.
Problem:
Within the scipts I've the variable MAJOR_VER, MINOR_VER and BUILD_NR. I would like to pass these with NMAKE in such way that I can use those variables (Macro's) to fill in the VERSIONINFO-resource: the file + product version entires. This structure is already moved to .RC2-file so its in our control.
When manually define them in a header-file and include this in RC2-file (as mentioned in MSDN: Q237870) this works.
But...
I want to pass this info via batch-file (NMAKE), iso calling a script which modifies a headerfile. Anyone suggestions?
Thanks in advance,
EiSl
|
|
|
|
|
For some reason, my C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB directory disappeared yesterday.
This is somewhat of a problem as I can't compile my programs anymore
Now, my biggest problem is that my Visual C++ cd is in Europe and I'm in the Carribean at this moment.
You might say: hey, what's the problem, go and enjoy the beach and the sun and forget about programming but I should really appreciate it if someone can send me a zip file with the contents of C:\Program Files\Microsoft Visual Studio\VC98\MFC\LIB (with mfc42d.lib, ...) to wjans@aqualectra.an?
I'm using Visual C++ 6.0 by the way.
Thanks in advance.
Wim
|
|
|
|
|
Are you sure you can handle such e-mails?
I've checked, but the LIB-directory is 43MB in size (at my PC), and ZIPing won't make it much smaller.
Cheers,
EiSl
|
|
|
|
|
Hi,
Hmm, I didn't realise it was this huge.
Is it possible for you to put it on a website or something like that so I can ftp it?
The zip file is just for easyness, so I have all the files in one cabinet
Thanks!
Wim
|
|
|
|
|
|
Hi Philip,
Thanks for the zip file.
I've downloaded it and everything seems to work again!
I really appreciate it that you've helped me out!
Thanks
Wim
|
|
|
|
|
Still need it? I can upload to my site. I got 14M zipped (49 unzipped)
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
hi
i have a "char* printername" variable is there. in this variable i want to store the selected printername. i assign this value to "dmDeviceName" structure member of DEVMODE structure. it's giving data type conversion error.
dmDeviceName datatype is TCHAR or BCHAR.
how can i assign my value to that. please help it's very urgent.
thank you
|
|
|
|
|
Instead of using char* I would recommend using CString if you are using MFC or WTL. If not then use std::string to store the name of the printer.
Third option would be to use a TCHAR printername[ 256 ]; to store the name of the printer. Then when you want to store it use _tcsncpy( ) to copy the name of the printer from dmDeviceName to this buffer.
But I would recommend using a string class - either CString or std::string.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
in <wingdi.h> :
#ifdef UNICODE
typedef WCHAR BCHAR;
#else
typedef BYTE BCHAR;
#endif
How low can you go ? (MS rant)
|
|
|
|
|
<br />
CMyView::OnChar(...)<br />
{<br />
PostThreadMessage(id,msg,0,0);<br />
}<br />
when i type with less than 130ms time intervals between keystrokes a deadlock results in the app's main thread.Any help would be greatly appreciated.
|
|
|
|
|
Any more info about the processing thread?
What does it do with the messages and how does it do it?
What kind of "deadlock" are you having?
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
Sir, I want to flush out the socket buffer. But I can't get the way to do that. Help me....
C.R.Naik
|
|
|
|
|
you can't AFAIK.
Btw, the proper sequence for closing a TCP connection is:
Finish sending data.
Call shutdown() with the how parameter set to 1.
Loop on recv() until it returns 0.
Call closesocket().
http://tangentsoft.net/wskfaq/newbie.html#normalclose
M
|
|
|
|
|
How can I move a CTreeCtrl item to a other position?
Item 1
SubItem 11
SubItem 12
SubItem 13
Item 2
SubItem 21
SubItem 22
SubItem 23
So I want to move Item 2 with all subitems (up or down):
Item 2
SubItem 21
SubItem 22
SubItem 23
Item 1
SubItem 11
SubItem 12
SubItem 13
How can I make this? (I want to move the current selected item with all subitems up or down)
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
There's no built in method that does this. The only way I'm aware of is to manually walk the tree, create new items with the same attributes as the old ones and finally delete the old ones. It would probably be a good idea to disable redrawing in the control while doing this ( m_wndTreeCtrl.SetRedraw( FALSE ); at the beginning and m_wndTreeCtrl.SetRedraw( TRUE ); when everything is finished.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I have a MFC MDI program, where I want to have in their own
MDIchildframe windows both CScrollView based view and CListView
based view. (Data neatly in CListView window, graphics in CScrollView window)
How can I accomplish that?
TIA
-Marko
|
|
|
|