|
You need more styles than just LBS_SORT, like, for instance WS_CHILD and WS_VISIBLE, although the latter can be done by clb.ShowWindow(SW_SHOWNA).
Steve S
|
|
|
|
|
You need more styles than just LBS_SORT . Add to that:
WS_CHILDWINDOW<br />
WS_VISIBLE
While not required, you might also need:
WS_TABSTOP<br />
LBS_NOTIFY<br />
LBS_SORT<br />
LBS_NOINTEGRALHEIGHT
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I presume the problem is not with window styles. You are creating the CListBox control object within the local scope. The object will get deleted once the program control exits the function. So try something like this:
CListBox m_pclb; //In header ( .h file )
In .CPP
m_pclb->Create(WS_VISIBLE | LBS_SORT,CRect(10,10,100,150),this,123);
this->Invalidate(TRUE);
This should work!!!
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Good catch!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I have a small application that doesn't use MFC, but i'd like to alter the listbox's so each item can be displayed in it's own colour.
I've searched these forums and google, but can't find any reference to non-mfc code to do this ... there is plenty of mfc stuff around though.
Hoping someone will know of a resource/example i can look at, else i'll have to convert the app to MFC.
ScorpioMidget
|
|
|
|
|
|
Many thanks for the link, should have tried msdn myself
ScorpioMidget
|
|
|
|
|
I'm making a mfc dialog app and was wondering if this type of program can access a seperate file. I was hopping for the user to be able to input data (mainly text) while the mfc dialog app was running, be able to save it in some type of file, and then retrieve it at a later date. I'm new to mfc, any help would be great, if possible please state which functions need to be used to create/retrieve the data or where they can be found on the internet. Thank you.
|
|
|
|
|
http://msdn.microsoft.com[^]
"It is better to remain silent and be thought a fool than to open one's mouth and remove all doubt." - Abraham Lincoln
|
|
|
|
|
Anonymous wrote:
...if possible please state which functions need to be used to create/retrieve the data or where they can be found on the internet.
It sounds like you'll need to use a CStdioFile object for reading from and writing to a text file. Google the Internet for tons of examples. MSDN has plenty, too.
CStdioFile file("mainly.txt", CFile::modeCreate | CFile::modeWrite);
file.WriteString("This is some text that the user entered\n");
...
CString strText;
file.ReadString(strText);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I need a way to write some binary data to a floppy. I tried using fopen("A:\\","wb") but that doesnt work because it cant open the file descriptor. In linux u can do something like that though. So how do i get a handle to the floppy? (I'm not talking about any files here or anything, i need to be able to write to the bootsector)
Thanks!
Kuniva
--------------------------------------------
|
|
|
|
|
|
fopen() requires a filename, not just a path.
FILE *f = fopen("a:\\myfile", "wb");<br />
fprintf(f, ...);<br />
fclose(f);
Now, in order to write to the disk's boot sector, I'm not sure how that'd be done. I have a suspicion that CreateFile() might be used as it can access physical disks, rather than just drives like C: and D:
Windows NT comes with a utility called DiskProbe, which is a low-level disk editor.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hey,
I want to change my process security token to another user.
basically what I need is when the app loads, it displays a user/pass dialog.
and then it changes the security token of the process as if it was run as the entered user/pass. according to what I heard, I can do something like this in two ways. 1) making another application that will display the dialog and then open my application with Api's like CreateProcessAsUser or CreateProcessWithLogon. 2) Use impersonation to change the security token of the process. I really prefer the second way, but I don't know where to start. and I don't know if it really is possible, I only found clues on how to impersonate a thread.. not a process.
Waiting for answer..
Arik Poznanski
|
|
|
|
|
Use LogonUser(), and pass the resulting handle into ImpersonateLoggedOnUser(). Just use RevertToSelf() to switch back to "the real you".
|
|
|
|
|
If you want your app to run on things other than XP (ie W2K, NT4) then there is another issue, which is that you must run your app from an account which originally has SeTCBPrivilege. This is off by default (sensibly) for most users. With NT and W2K you can use the NTRIGHTS app from the resource kit to turn it on, but I'd think about why, to be honest, since it's a potential hole in system security.
Steve S
|
|
|
|
|
Is it possible to display an Image say .GIF, .JPEG in a picture control?? I need to display picture in a dialog , is there any other way except .BMP
Warm Regards,
KKR
|
|
|
|
|
Start here:
http://www.codeproject.com/bitmap/
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I am writing a piece of code to read in data a piece of hardware at a byte at a time.
I have a structure which is made up as follows:
typedef struct {<br />
unsigned short int U16_DemandedDeflection; <br />
unsigned short int U16_DemandedToolface;<br />
unsigned short int U16_Beta; <br />
char U8_Toolface_K; <br />
unsigned short int U16_PumpBackThreshold;<br />
unsigned short int U16_RpmAveragingFactor;<br />
unsigned short int U16_WalkAroundAngle;<br />
char U8_WalkAroundDwellTime;<br />
unsigned short int U16_DemandedMagneticToolface<br />
unsigned short int U16_MagneticBeta;<br />
char U8_ToolfaceControlMode;
unsigned short int U16_NeutralThreshold;<br />
char U8_Spare[3];<br />
}SCB_ControlSystem;
I have set up a pointer to point to the start of the structure
unsigned char * pSCB_Byte_Pointer;<br />
<br />
pSCB_Byte_Pointer = (unsigned char *)&SCB_ControlSystem;
The visual C++ program does the following:
Repeat
Read in the char
Put the char into the memory pointed to by pSCB_Byte_Pointer
If it is a two byte number reverse the contents of memory
Until
The read in and the poke part of the program works fine, but when I look at the structure the value for U16_PumpBackThreshold is incorrect. (
After single stepping and looking at the Microsoft website I have found that short int’s are setup on the even boundary.
I want to force the compiler to be able to put short int’s on an odd or even boundary.
Or
Come up with an efficient way of writing the code (The structure of the data has not been finalised yet)
The Fox
|
|
|
|
|
TheFox wrote:
I want to force the compiler to be able to put short int’s on an odd or even boundary.
Try using #pragma pack(1). This forces the compiler to use packing alignment for structure and union members. Make sure you use #pragma pack (push, ...) and #pragma pack (pop, ...) either side so that you don't realign other data structures.
|
|
|
|
|
In my mFC app,i have 2 CPP files.In CPP 1 i have a array of structs as like this:
struct Menu{
char* pcTitle;
char* pcItem;
int nCount;
int nID;
};
struct Menu arrMenu[10];
I want to access this arrMenu[10] in my 2nd CPP file and declared as
extern struct Menu arrMenu[10];
When try to use this struct in CPP2 file i get error as :
" 'struct Menu *' : unknown size
"use of undefined type 'Menu'"
Pls help how to use arrMenu[10] as extern variable and use it in CPP 2 file..
Thnks
Ram
|
|
|
|
|
Declare the Menu structure in the header of CPP1, and include that file in CPP2. Thats all...
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
A .H file...
---------------------------------------------
#ifndef Some_H
#define Some_H
#import "Some.tlb" no_namespace, \
named_guids
#endif // Some_H
---------------------------------------------
and the Compiler is giving following stupid error...
---------------------------------------------
error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
---------------------------------------------
Helppppppppp!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! requested
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
The type library you have referenced uses another type library that was not referenced with #import. This other .tlb file was not found by the compiler, so go and check it out.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I'm trying to exit my MFC application but from a different thread
The separate thread is started using timeSetEvent(), this separate timer is used to loop through received udp messages. When one of this messages tells me that the overall application(made os differennt exec) setup is wrong, I must exit.
when using PostMessage with WM_QUIT, I get a bunch of pointers which are null
Is there a better way to exit... or maybe I should not use the timeSetEvent() function?
|
|
|
|